getline在vc6.0中的一个小问题
下面小程序中为什么在vc++6.0中运行结果却得不到所需的结果?#include <iostream>
#include <string>
using namespace std;
int main ()
{
string mystr;
cout << "What's your name? ";
getline (cin, mystr);
cout << "Hello " << mystr << ".\n";
cout << "What is your favorite color? ";
getline (cin, mystr);
cout << "I like " << mystr << " too!\n";
return 0;
}
在VC++6.0运行,其结果如下:(下面黑粗体字是键盘输入的)
What's your name? Aqua
Hello Aqua.
What is your favorite color? blue
I like too!
为什么在所需结果"I like blue too!"中会缺少"blue"?