今天看C++Primer的时候发现一个问题,getline需要输入2次回车才会显示结果,上网找了一下,发现是VC6.0的原因,修复原因如下:
(1)建立一个1.CPP
(2)输入#include <string>
(3)右击<string>,选择“打开文档<string>”
(4)用CTRL+F查找 else if (_Tr::eq((_E)_C, _D))
else if (_Tr::eq((_E)_C, _D))
{_Chg = true;
_I.rdbuf()->snextc();
break; }
将上面的代码修改为
else if (_Tr::eq((_E)_C, _D))
{_Chg = true;
// _I.rdbuf()->snextc();
// (this comments out the defective instruction)
_I.rdbuf()->sbumpc(); // corrected code
break; }
保存退出后即可修复这个问题。
转载自:http://www.cnblogs.com/EnCaL/archive/2012/12/03/2800138.html