[英]Visual Studio: Create a Hello World app in C?
How can I create a basic C app in Visual Studio, be it 2010 Ultimate or 2008 Professional? 如何在Visual Studio中创建基本的C应用程序,无论是2010 Ultimate还是2008 Professional? I have searched through the project templates, and can find plenty for C++, but none for C. 我搜索了项目模板,可以找到很多C ++,但没有C语言。
(I'm hoping that the compiler and debugger will be built in.) (我希望内置编译器和调试器。)
New project/Win32 Console Application/Empty project. 新项目/ Win32控制台应用程序/清空项目。
Add a file called "hello.c" (important that it's .c) 添加一个名为“hello.c”的文件(重要的是它的.c)
Type out a basic hello-world: 输入一个基本的hello-world:
#include <stdio.h>
int main()
{
printf("Hello world\n");
return 0;
}
Compile, execute... PROFIT! 编译,执行......利润!
Visual Studio doesn't have a separate compiler for C, it uses the C++ compiler for C code. Visual Studio没有针对C的单独编译器,它使用C ++编译器来实现C代码。 You can tell it to restrict itself to legal C syntax by using a compiler switch or by renaming the .cpp file to .c 您可以通过使用编译器开关或将.cpp文件重命名为.c来告诉它将自己限制为合法的C语法
Edit: I'm still using 2005 on this machine, so it might not be in the same place, but try this 编辑:我仍然在这台机器上使用2005,所以它可能不在同一个地方,但试试这个
In addition to changing the file extension, you may need to change the compiler settings: Settintgs of Application->C/C++->addition->compiler such... You must take /TC for basic C and /TP for C++. 除了更改文件扩展名外,您可能还需要更改编译器设置:应用程序的设置 - > C / C ++ - >加法 - >编译器......您必须使用/ TC作为C ++的基本C和/ TP。 https://msdn.microsoft.com/ru-ru/library/032xwy55.aspx
Good Luck. https://msdn.microsoft.com/ru-ru/library/032xwy55.aspx
祝你好运。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.