#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”文件。代码在不包含文件的情况下工作正常。
关于c++ - Cin 和 Cout 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38115918/