//getline() function use #include <iostream> #include <string> using namespace std; intmain() { string s1,s2; getline (cin, s1); getline(cin,s2,' '); cout<<"You inputed chars are : \n"<<s1<<endl; cout<<"You inputed chars are : \n"<<s2<<endl; return 0; }
It can be seen that the second character entered contains a space character in the middle, and the characters after the space are not stored in the string s2.