首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

新手提问一个getline有关问题

2013-01-21 
新手提问一个getline问题#include iostream#include stringusing namespace stdint main(){string a

新手提问一个getline问题


#include <iostream>
#include <string>
using namespace std;

int main()
{
string a;
string b;
string c;
getline(cin,a);
cout << a << endl;
cin >> b;
cout << b << endl;
getline(cin,c);
cout << c << endl;
return 0;
}


上面代码中getline(cin,c)没有执行效果,为什么呢? 以及怎么解决这个问题?
新手 求教~~ 
[解决办法]

fflush(stdin);
getline(cin,c);

[解决办法]
你的是vc6吧?
http://blog.csdn.net/testing2007/article/details/5314653
还是用cin.getline吧。不过这个需要提前知道长度。

热点排行