Visual Studio Express 2013 初学者的 C++ 设置

Bla*_*lls 2 c++ installation visual-studio

我只是问初学者程序员一个通用问题:如何为初学者设置/配置 Visual Studio Express 2013?

我问是因为我在编译一个简单的“Hello World”程序时遇到了麻烦。

这是我的代码:

#include <iostream>

int main()
{
cout << "Hello World!" << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)

这些是错误:

Error   1   error C2065: 'cout' : undeclared identifier c:\users\blake\documents\visual studio 2013\projects\hello world\hello world\app.xaml.cpp   6   1   Hello world
Error   2   error C2065: 'endl' : undeclared identifier c:\users\blake\documents\visual studio 2013\projects\hello world\hello world\app.xaml.cpp   6   1   Hello world
Warning 3   warning C4447: 'main' signature found without threading model. Consider using 'int main(Platform::Array<Platform::String^>^ args)'. c:\users\blake\documents\visual studio 2013\projects\hello world\hello world\app.xaml.cpp   8   1   Hello world
    4   IntelliSense: identifier "cout" is undefined    c:\Users\Blake\Documents\Visual Studio 2013\Projects\Hello world\Hello world\App.xaml.cpp   6   2   Hello world
    5   IntelliSense: identifier "endl" is undefined    c:\Users\Blake\Documents\Visual Studio 2013\Projects\Hello world\Hello world\App.xaml.cpp   6   28  Hello world
Run Code Online (Sandbox Code Playgroud)

我已经关闭了预编译头文件,但我仍然遇到问题。

我知道如果我把 STD:: 放在 cout 和 endl 的前面,我会摆脱两个错误。主要是因为我没有使用过命名空间 std。- 我可以自己解决这个问题。

还有什么我需要做的吗?- 我需要纯粹为初学者设置它,所以我可以直接编译和运行有点东西!

我在哪里运行编译的文件?

dgp*_*dgp 5

  1. 文件 -> 新建 -> 项目。
  2. 在 Visual C++ 项目类型窗格中,单击 Win32,然后单击 Win32 控制台应用程序。
  3. 键入项目名称,单击“确定”。
  4. 在 Win32 应用程序向导中,单击下一步,选择“空项目”,然后单击完成。
    • 这一步很重要。

完整指南的来源和链接:http : //msdn.microsoft.com/en-us/library/ms235629.aspx
带有图像的 Visual Studio Express指南:http : //cplusplus.com/doc/tutorial/introduction/visualstudio

现在下面的代码应该可以工作:

#include <iostream>

using namespace std;

int main()
{
    cout << "Hello World!" << endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

就目前而言,控制台窗口将在程序执行完毕后立即退出。您可能希望在 return 语句之前设置断点以查看程序的输出。