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:




Learn C: Special Characters

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

Special or control characters are invisible on the screen. They have special purposes usually to do with cursor movement and are written into an ordinary string or character by typing a backslash character \ followed by some other character.

In the hello example, the special character is “\n”.

These characters are listed below.

Special CharacterDescription
\bbackspace BS
\abeeping sound
\nnew line NL (like pressing return)
\rcarriage return CR (cursor to start of line)
horizontal tab HT
\"double quotes (not all versions)
\'single quote character '
\\backslash character \

Learn C: A variation of the first program

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

#include <stdio.h>

void main()
    printf("Hello World");
    printf("This is my first program.\n");


The “\n” is a special character.  It means new line here.  Notice the 2 new lines in the hello program.

printf is a print function defined in stdio.h, that is also why there is an include statement in the beginning.

The “;” denotes the end of a statement.

Learn C: What are the resources available on the web to learn C?

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

There is actually quite a lot of resources available online that you can tap into.

Here, there are these few links that I have found:

  1. Tutorials Point – with good introduction
  2. How Stuff Work – a bit surprised to find C stuff here
  3. C Programming
  4. Programming Simplified – quite a lot of examples that you can try
  5. C Tutorial – created more for students majoring in Physics
  6. C4Learn – this site has some very good and short examples that you can try out
  7. GNU C – a programming tutorial

If you have come across any good C introduction on the web, please share the link.