0

Can anyone tell me how to input a string in C++...I get compile errors

31st Dec 2016, 6:58 PM
Syed Naqvi
Syed Naqvi - avatar
2 Réponses
+ 4
just do string a="this is string"; to output it cout<<a; and to get input string b; cin>>b;
31st Dec 2016, 7:21 PM
shanky
shanky - avatar
+ 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.
31st Dec 2016, 7:12 PM
Wen Qin
Wen Qin - avatar