How to use cin and string together? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to use cin and string together?

19th May 2017, 4:58 AM
Sarthak
Sarthak - avatar
2 Answers
+ 5
1)getline (cin,a); //line 2)cin>>a; //single word
19th May 2017, 5:06 AM
Pixie
Pixie - avatar
+ 4
3) cin.getline(str_name,no_of_chars); If you have a c-string... //Null Terminated Array of Characters...
19th May 2017, 5:08 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar