Cin 和 Cout 不工作
Cin and Cout not working
#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,编译器说它们是未声明的标识符。我查看了此处和其他论坛上的所有答案,none 的解决方案似乎可以解决问题。提前致谢。
希望您尝试将 "stdafx.h" 文件包含在正确的路径中。该代码在不包含文件的情况下工作正常。
#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,编译器说它们是未声明的标识符。我查看了此处和其他论坛上的所有答案,none 的解决方案似乎可以解决问题。提前致谢。
希望您尝试将 "stdafx.h" 文件包含在正确的路径中。该代码在不包含文件的情况下工作正常。