3.2.2-2

    技术2025-06-18  10

    int main() {     string s;     getline(cin,s);//getline接受两个形参:输入流和string对象                    //从输入流的下一行读取,并保存到string,但不包括换行符,遇到换行返回                    // hellow world回车     cout<<s<<endl;//hellow world   system("pause"); } ------------------------------------------------------------------------------------------------ int main() {     string line;     while(getline(cin,line))

            cout<<line<<endl;

     

    //Because line does not contain a newline, we must write our own if we want the strings written one to a line. As //usual, we use endl to write a newline and flush the output buffer. hellow //input hellow //output world  //input world  //output ^Z 请按任意键继续. . .   system("pause"); }

    最新回复(0)