VC++6的BUG?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string str1;
string str2;
cout < < "输入你的名字 ";
getline (cin,str1);
cout < < "你父亲的名字是 ";
getline (cin,str2);
cout < < str1 < < "是 " < <str2 < < "的儿子 " < <endl;
return 0;
}
我在我的 V C++ 6.0上运行以后 显示
输入你的名字bill jean
你父亲的名字是sam jean
bill jean是的儿子
Press any key to continue
本来应该显示的是
bill jean是sam jean的儿子
我不明白我以为是我写错了
我把源文件发给我一个朋友 他运行后是
输入你的名字bill jean
你父亲的名字是sam jean
bill jean是sam jean的儿子
Press any key to continue
结果是正确的
首先我要肯定的是 源文件绝对没有错
但是 程序提示 “输入你的名字”的时候
我需要按2次回车 才能进行下一步
输入你的名字bill jean
//注意看这一行。
你父亲的名字是sam jean
我朋友的编译系统是 dev-c++ 4.9.2
我现在只能判断 这是VC6里面的BUG了。。请问有什么办法避免吗?
[解决办法]
问题已帮你解决,只是你的分太少了点啊!