0
Can anyone tell me how to input a string in C++...I get compile errors
2 Réponses
+ 4
just do
string a="this is string";
to output it
cout<<a;
and to get input
string b;
cin>>b;
+ 2
Make sure the variable is string, and if you want, you can use a converter to convert the input to a string(optional but recommended). Finally, use a try-catch statement incase the user inputs empty(aka a null, but it most likely will result in an empty string) or some other werid stuff.