Cin和Cout无法正常工作

时间:2016-06-30 06:56:07

标签: c++ visual-studio-2015 cin

#include <iostream>
#include "stdafx.h"
#include <string>

using namespace std;

int main()
{
    //Variables in which student info is stored
    string name = "";

    //asks user for their name
    cout << "/nHello, my name is Hal, what is your name? ";

    cin >> name;

    cout << "/nWelcome to C++ ";
    cout << name;
    cout << ", let the adventure begin!";

    return 0;
}

我似乎无法开始工作的真正基本代码。在任何地方,我都有cin或cout编译器说他们是一个未声明的标识符。我已经查看了这里和其他论坛的所有答案,但似乎没有一个解决方案可以修复它。提前谢谢。

1 个答案:

答案 0 :(得分:3)

希望您有正在尝试包含在正确路径中的“stdafx.h”文件。代码工作正常,不包含文件。

相关问题