如何使用Visual Studio C ++编译器? [英] How to use Visual Studio C++ Compiler?

查看:489
本文介绍了如何使用Visual Studio C ++编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近安装了Visual Studio 2013.我可以创建一个新项目(Visual C ++),但我必须遇到的错误是,我无法运行应用程序。这是我试图在Visual Studio 2013上运行的代码。

I recently installed Visual Studio 2013. I can create a new project (Visual C++), but the error I have to come across is that I cannot run the app. Here is the code that I'm trying to run on Visual Studio 2013.

#include <iostream>
using namespace std;

int main() {
    cout << "Hello World";
    return 0;
}



我确定这个代码会运行,并会输出 hello world ,但在Visual Studio中它给我的问题,说:

I am sure this code would run, and will output hello world, but in Visual Studio it gives me issues, saying:


值不能为空,

参数名称:solutionDirectory。

Values cannot be null,
Parameter name: solutionDirectory.

我在这里缺少什么?

这是一个图片:

推荐答案

在Visual Studio中,只需打开一个 .cpp 文件,并期望它运行。您必须先创建一个项目,或在某个现有项目中打开.cpp。

In Visual Studio, you can't just open a .cpp file and expect it to run. You must create a project first, or open the .cpp in some existing project.

在您的情况下,没有项目,因此没有构建

In your case, there is no project, so there is no project to build.

转到文件 - >新 - >项目 - > Visual C ++ - > Win32控制台应用程序。您可以取消选中为解决方案创建目录。在下一页上,请务必选中空项目。

Go to File --> New --> Project --> Visual C++ --> Win32 Console Application. You can uncheck "create a directory for solution". On the next page, be sure to check "Empty project".

然后,您可以添加 .cpp 文件您在Visual Studio之外创建的右键单击解决方案资源管理器文件夹图标源和添加 - >现有项目。

Then, You can add .cpp files you created outside the Visual Studio by right clicking in the Solution explorer on folder icon "Source" and Add->Existing Item.

显然,你可以用这种方式创建新的.cpp(添加 - >新建)。

Obviously You can create new .cpp this way too (Add --> New). The .cpp file will be created in your project directory.

然后,您可以按ctrl + F5进行编译而无需调试,并且可以在控制台窗口看到输出。

Then you can press ctrl+F5 to compile without debugging and can see output on console window.

这篇关于如何使用Visual Studio C ++编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆