C++ 中的“读一行” getline(cin , s) cin.getline(s, 100)

#include<string> using namespace std; int main(int argc, char *argv[]) { string s; cin>>s; cout<<s<<endl;; return 0; }
#include <iostream>
#include<string>
using namespace std;
int main(int argc, char *argv[])
{
string s;
cin>>s;
cout<<s<<endl;
return 0;
}
****************************************************************************************************************************

#include <iostream> #include<string> using namespace std; int main(int argc, char *argv[]) { string s; getline( cin, s) ; cout<<s<<endl; return 0; }
#include <iostream>
#include<string>
using namespace std;
int main(int argc, char *argv[])
{
string s;
getline( cin, s) ;
cout<<s<<endl;
return 0; }

#include <iostream> #include<string> using namespace std; int main(int argc, char *argv[]) { string s; while (getline(cin,s)) cout<<s<<endl; return 0; }
#include <iostream>
#include<string>
using namespace std;
int main(int argc, char *argv[])
{
string s;
while ( getline( cin, s) )
cout<<s<<endl;
return 0; }
*********************************************************************************************************
#include <iostream> #include <string> using namespace std; main () { char s[100]; cin.getline (s, 100); cout << name <<endl; }
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步