C++.我的"你好世界"计划有什么问题?

Ano*_*ous -1 c++

有人能告诉我这有什么问题.当我输入"你好吗"时,它不回复"我很好."!请帮忙!!!

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

int main()
{
    string x;

    cout << "Write something.." << endl;
    cin >> x;

    if (x == "How are you?") {
        cout << "I am fine." << endl;
    }

    system("PAUSE");
}
Run Code Online (Sandbox Code Playgroud)

qwr*_*qwr 8

使用std::getline获取线.原因std::cin>>只会得到第一个字.

固定代码将是这样的:

cout << "Write something.." << endl;
std::getline (std::cin,x);

if (x == "How are you?"){
    cout << "I am fine." << endl;
}
Run Code Online (Sandbox Code Playgroud)