C++ STL getline function

//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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325555105&siteId=291194637