Cin和Cout不起作用


#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的任何地方,编译器都说它们是未声明的标识符。我看了所有的答案在这里和其他论坛,它似乎没有解决方案来解决它。

希望你有"stdafx.h"文件,你正试图包括在正确的路径。没有包含文件,代码也可以正常工作。

最新更新