0

How to input string in c++

14th Oct 2016, 8:16 AM
philip
philip - avatar
5 Answers
+ 1
string s; cin >> s;
14th Oct 2016, 10:01 AM
Zen
Zen - avatar
+ 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.
14th Oct 2016, 10:53 AM
Vasileios Koukoutsas
Vasileios Koukoutsas - avatar
+ 1
Remember to add <string> library
14th Oct 2016, 12:37 PM
Suiko
Suiko - avatar
+ 1
you can also use the getline function which allows you to take spaces as input , string input; getline(cin,input); for example.
14th Oct 2016, 12:45 PM
Fhatuwani Luvhengo
Fhatuwani Luvhengo - avatar
0
by string keyword
14th Oct 2016, 3:46 PM
manish chouhan
manish chouhan - avatar