0
How to input string in c++
5 Answers
+ 1
string s;
cin >> s;
+ 1
cin is used to read user's input.
you can define the variable in cin>>var as whatever type you expect the user to input e.g. int for integer string for text bool for boolean etc.
+ 1
Remember to add <string> library
+ 1
you can also use the getline function which allows you to take spaces as input ,
string input;
getline(cin,input);
for example.
0
by string keyword