您的位置:首页 > 编程语言 > C语言/C++

getline c分格和c++风格

2017-08-14 16:48 190 查看
#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 字符串