c++ - Cin 和 Cout 不工作

标签 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,编译器说它们是未声明的标识符。我已经查看了这里和其他论坛上的所有答案,但似乎没有任何解决方案可以解决这个问题。提前致谢。

最佳答案

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

关于c++ - Cin 和 Cout 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38115918/

相关文章:

c++ - 组合键与 ENTER 键

c++ - 重复和空格

c++ - 以特定值拆分数组 C++

typescript - ASP.NET 核心项目 : How to keep Typescript from Compiling

visual-studio-2015 - 安装NuGet软件包时未找到项目“默认”错误

c++ - cin 溢出到后面的 cin

c++ - 使用 C++ 读取管道输入

c++ - OpenCV imwrite 保存黑色 png

c++ - 将 focusOutEvent 的函数分配给小部件

c# - 构建一个 web 项目破坏了解决方案中第二个的编译版本