简体   繁体   English

如何在Visual Studio 2012 for Windows 8上编译和执行C程序?

[英]How to compile and execute C program on Visual Studio 2012 for Windows 8?

I was looking for a C compiler for Windows 8 and then came to know that I can compile C programs on Visual Studio. 我正在为Windows 8寻找一个C编译器,然后才知道我可以在Visual Studio上编译C程序。

Microsoft offers a walkthrough for the same, but I don't like it since it includes writing program in text editor and use of command prompt frequently, I am looking for more like a Turbo C++ interface. 微软提供相同的演练 ,但我不喜欢它,因为它包括在文本编辑器中编写程序和频繁使用命令提示符,我正在寻找更像Turbo C ++接口。

Is there anyway I can run and compile programs directly in Visual Studio 2012 for windows 8 itself? 无论如何,我可以直接在Visual Studio 2012中为Windows 8本身运行和编译程序吗?

Or if that's not possible, what alternatives I have for windows 8? 或者,如果这不可能,我有什么替代Windows 8?

From the page you posted: 从您发布的页面:

By default, the Visual C++ compiler treats all files that end in .c as C source code, and all files that end in .cpp as C++ source code. 默认情况下,Visual C ++编译器将以.c结尾的所有文件视为C源代码,将所有以.cpp结尾的文件视为C ++源代码。

Now create any C++ project type you want and when you add the files, ensure they end in .c and you are done. 现在创建您想要的任何C ++项目类型,并在添加文件时确保它们以.c结尾并且您已完成。

Since you asked for alternatives (not clear if you meant even alternative IDEs and/or compilers): 既然你要求替代方案(不清楚你是否意味着替代IDE和/或编译器):

You could try the free Code::Blocks IDE which has support for MINGW , which includes a port of GCC (Gnu Compiler Collections) for Windows. 您可以尝试免费的Code :: Blocks IDE ,它支持MINGW ,其中包括用于Windows的GCC(Gnu编译器集合)端口。 An alternative, and sometimes easier to install, port of GCC based on MINGW is TDM-GCC . 另一种基于MINGW的GCC端口,有时更容易安装,是TDM-GCC Code::Blocks can also be configured to work with other toolchains. Code :: Blocks也可以配置为与其他工具链一起使用。

An advantage of using GCC is that it is the default compiler for Linux systems, so if you will happen to code for Linux too, you could "reuse" your knowledge of the GCC compiler you used on Windows. 使用GCC的一个优点是它是Linux系统的默认编译器,因此如果你也碰巧为Linux编写代码,你可以“重用”你在Windows上使用的GCC编译器的知识。

Another alternative IDE could be eclipse , with its CDT extension , aimed at C/C++ development (can be configured to work with GCC or with many other toolchains). 另一个替代IDE可能是eclipse ,其CDT扩展 ,旨在进行C / C ++开发(可以配置为与GCC或许多其他工具链一起使用)。 Much heavier than Code::Blocks, but with much more features. 比Code :: Blocks重得多,但具有更多功能。

you can use visual studio as TURBO C++ 你可以使用visual studio作为TURBO C ++

But here 但在这里

if you want to compile single file 如果你想编译单个文件

create program.c 创建program.c

file->new->c++file->open

then write c code and save it with extension .c 然后编写c代码并用扩展名.c保存

Now you need to create new project and file->new->project add program.c to this project. 现在您需要为此项目创建新项目和file->new->project add program.c。

and compile the project By using build->compile . 并使用build->compile项目。 before that change compile as with the 在那之前改变编译与

project->properties.

The last time I used Turbo C++ (in the early 90s), it was an IDE just like Visual Studio. 我最后一次使用Turbo C ++(在90年代早期),它就像一个IDE,就像Visual Studio一样。

Both Turbo C++ and Visual Studio offer command line tools. Turbo C ++和Visual Studio都提供命令行工具。

From the start menu, find the Visual Studio tools menu, there should be a command line shortcut there that allows you access to the command line (cl.exe) tools. 从开始菜单中,找到Visual Studio工具菜单,应该有一个命令行快捷方式,允许您访问命令行(cl.exe)工具。

If you have makefiles, then you can use nmake rather than make. 如果你有makefile,那么你可以使用nmake而不是make。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM