|
-
Jan 2nd, 2001, 04:23 AM
#1
Thread Starter
Hyperactive Member
Another question: how can I use cin with strings?
Code:
string data;
cin>>data; //gives an error
WP
-
Jan 2nd, 2001, 06:12 AM
#2
Monday Morning Lunatic
If you want to use strings then you need to use the proper STL iostreams library:
Code:
#include <iostream> /* No .h extension! */
#include <string>
using namespace std;
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jan 2nd, 2001, 04:34 PM
#3
if you want to be able to get more than one word(like if somebody typed "hello world" hello would be the only one gathered), do this
Code:
string str;
getline(cin,str);
cout << str;
-
Jan 3rd, 2001, 05:01 AM
#4
Thread Starter
Hyperactive Member
??
but the user has to press twice on the return button
WP
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|