今天看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))

(5)

1 else if (_Tr::eq((_E)_C, _D))
2            {_Chg = true;
3              _I.rdbuf()->snextc();
4             break; } 

将上面的代码修改为

1 else if (_Tr::eq((_E)_C, _D))
2         {_Chg = true;
3         //  _I.rdbuf()->snextc(); 
4         // (this comments out the defective instruction) 
5         _I.rdbuf()->sbumpc(); // corrected code 
6         break; } 

保存退出后即可修复这个问题。