Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 11-26-2004, 03:50 AM   #1 (permalink)
cracksevi
Registered User
 
Join Date: Oct 2004
Posts: 14
cracksevi is on a distinguished road
Send a message via ICQ to cracksevi
re hi

hello peepz after some while !
im trying to continue from where i left last time
now at char strings



#include <iostream.h>
int main()
{
char hello [4];
cout << "say sth and i will repeat\n";
cin.getline (hello,4);
cout << hello;
return 0;
}



see hello is limited to 4....what if i dont want any limit?
the code with no limit can explain enuf i hope
thanx
cracksevi is offline   Reply With Quote
Old 11-26-2004, 05:59 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,720
redhead is on a distinguished road
then use type string instead of char.
Code:
#include <iostream>
#include <string>
using namespace std;

int main()
{
   string hello;
   cout << "say sth and i will repeat\n";
   cin >> hello;
   cout << hello;
   return 0;
}
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 11-26-2004, 08:27 AM   #3 (permalink)
cracksevi
Registered User
 
Join Date: Oct 2004
Posts: 14
cracksevi is on a distinguished road
Send a message via ICQ to cracksevi
well well...this one looks good too
but there is a prob that it doesnt recognize the space char...
if i write "abc def" it shows only "abc"
cracksevi is offline   Reply With Quote
Old 11-26-2004, 09:41 AM   #4 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Code:
#include <iostream>
#include <string>
using namespace std;

int main()
{
   string hello;
   cout << "say sth and i will repeat<<endl;
   getline(cin, hello);
   cout << hello;
   return 0;
}
__________________
Valmont is offline   Reply With Quote
Old 11-26-2004, 11:41 AM   #5 (permalink)
cracksevi
Registered User
 
Join Date: Oct 2004
Posts: 14
cracksevi is on a distinguished road
Send a message via ICQ to cracksevi
yeah great one again Val
cracksevi is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 01:03 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting