Another question: how can I use cin with strings?
WPCode:string data;
cin>>data; //gives an error
Printable View
Another question: how can I use cin with strings?
WPCode:string data;
cin>>data; //gives an error
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;
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;
but the user has to press twice on the return button
WP