Learn C: Using Visual Studio to compile a C program

This entry is part 7 of 7 in the series Learn C

The earlier posts were done using GNU C.

If you prefer, you could use the free version of Visual Studio Express from Microsoft.  This is a lot more easy to set up and unlike GNU C, you just have to download the Visual Studio Express and you are all set to write your first program.

Let’s walk through the process of writing your first C program.  You need to make a slight change to the source file name extension as the default setup for Visual Studio Express is in C++ with the cpp extension.

1.  The first step is to launch Visual Studio and from the file menu select New Project.



2.  As in the screenshot above, select Visual C++ and Win32 Console Application.

3.  Key in a new file name if you like.

4. The Win32 Application Wizard will be launched.


5. Click on next and the following page will be shown.


6. Select Console Application and click on Empty Project.

7. Deselect Precompile Header

8. Click on Finish

9.  An empty project similar to the screenshot below will be created.


10. Notice the Solution Explorer on the right of the screen.

11.  Right click on it and select Add -> New Item


12.  Change the file name to Hello.c as shown in the screenshot.

13.  The Hello.c file will be added to the Source File folder

14.  Paste the code below to the editor.

#include <stdio.h>

void main()
	printf("Hello World");

15.  Click on Local Windows Debugger


16.  This will compile and run the program.  The output will be as shown below: