#include <iostream>
using namespace std;
#include <string>
int main()
{
string str;
char buf[20];
cout << "input a line" << endl;
getline(cin, str);
cout << "str=" << str << endl;
cout << "input a line <20" << endl;
cin.getline(buf, 20);
cout << "buf=" << buf << endl;
if (!cin)
{
cout << "read erro state" << endl;
}
int n;
cout << "input an integer" << endl;
cin >> n;
cout << "n=" << n << endl;
return 0;
}
getline c分格和c++风格
最新推荐文章于 2023-05-15 19:49:41 发布