Visual Studio: create a Hello World application in C?

How to create a basic C application in Visual Studio, be it 2010 Ultimate or 2008 Professional? I looked through project templates and can find a lot for C ++, but not one for C.

(I hope the compiler and debugger are built in.)

+4
source share
3 answers

Visual Studio does not have a separate compiler for C, it uses the C ++ compiler for C code. You can say that it is limited to the legal C syntax using the compiler or by renaming the .cpp file to .c

Edit: I am still using 2005 on this machine, so it might not be there, but try this

  • Right-click on main.cpp in the solution explorer pane (right).
  • Select "Properties" (bottom of the menu)
  • Open the C / C ++ property group.
  • select "Advanced page"
  • Change the Compile As property to Compile As C (/ TC) Code
+3
source

New project / Console application Win32 / Empty project.

Add a file called "hello.c" (it is important that it .c)

Enter the basic hi-world:

#include <stdio.h> int main() { printf("Hello world\n"); return 0; } 

Compile, execute ... PROFIT!

+6
source

In addition to changing the file extension, you may need to change the compiler settings: Settintgs Application-> C / C ++ → add-on> compiler such ... You should take / TC for basic C and / TP for C ++. https://msdn.microsoft.com/ru-ru/library/032xwy55.aspx Good luck.

0
source

Source: https://habr.com/ru/post/1299849/


All Articles