Compile and Run C Programs using VS2008

How to Compile and Run C Programs using Microsoft Visual Studio 2008? Here is the answer…
In this article I will explain you how to use Visual Studio 2008 to compile and run C program. Compiling and running C Program is as easy as we do in Tourbo C++. Below is the procedure. Please note that the same method applies to Visual Studio 2010 too. So what are waiting for. Read the below article and leave some feedback…

Step 1: Go to Start menu->All Programs->Microsoft Visual Studio 2008->Visual Studio Tools->Visual Studio 2008 Command Prompt
Following screen will be displayed:

Visual Studio 2008 Command Prompt

Step 2: Create a text file with the name ‘FirstCProgram’ save it as ‘FirstCProgram.C’. Make sure that the extension is ‘.C’ and not ‘.txt’.

Step 3: Write your C program in ‘FirstCProgram.C’ or you can use the below code and save it.


void main(){
 printf(“First C Program”);

Step 4: Go to the directory (Folder in which you have saved your C Program) from the command prompt.
To go to one level back type ‘cd..’ and press ‘Enter’.
If you want to change the drive from ‘C:’ to ‘D:’ just type ‘D:’ and press ‘Enter’.
Let us suppose you want to go to folder named ‘Programs’ present in ‘D’ and you are in ‘C:’ drive then just type the commands in command prompt as shown in the below screenshot.

Go from one Directory to another from command Prompt

Step 5:Type the following command to compile your C Program as shown below.
Command: cl FirstCProgram.C

On successful compilation following screen will be displayed.

Compile C Program using Visual Studio 2008

After successful compilation, you can see FirstCProgram.obj file and FirstCProgram.exe file in your folder. You can ignore FirstCProgram.obj file as it is intermediate file. You can safely delete it if you don’t want that file to be in your computer.

Step 6: To run the program simply type FirstCProgram in your command prompt and press enter or you can directly click the.exe file that got created just after compilation.

Run C Program using Visual Studio 2008

Thats all folks. I will come up with a new article in another few days. Please provide your valuable comments about this article or anything related to this website. It would really help me in improving the website.

You may also like...

16 Responses

  1. Dennis says:

    Excellent article. Explained each and every steps very accurately. I will definitely refer this site to my friends who are new to C programming. This is the best C tutorial site i ever came across. Thanks for creating such a wonderful website.

  2. Anonymous says:

    very helpful….thanks……..

  3. Anonymous says:

    nice , thank you

  4. Anonymous says:

    best of best….:)
    thanks a ton…..

  5. Anonymous says:

    Excellent article. I was really fed with compiling a c program until I found this. Thanks a lot.

  6. venkeyanbu says:

    super article. Can i know how to run collection of c files at a time. i.e. my folder have so many .c files?

  7. pavan says:

    excellent article mate.Thanks a lot.i need java tutorials also with this kind of explanation.Is there any site then pls provide a link.Thank u very muck……

  8. Anonymous says:

    Till date i have confused myself with c concepts, but after read your blog i would get a clear.hats off to you.

  9. Sofi Boo says:

    How do u write a sentence and count its characters? in c program

  10. Anonymous says:


  11. I am saving c programs in D with in one folder. how i can run that c file from that particular folder. Is it possible

  12. I saved the C file in D drive within a folder. How i can run from that place itself?
    Is it possible

  13. Anonymous says:

    how can I compile c code with header file and run it

  14. PRAMOD says:

    nice post. Thank you.

  15. sagar kanade says:

    very nice…
    very helpfull…

Leave a Reply

Your email address will not be published. Required fields are marked *

FREE C Cheatsheet - Speed Up Your C Programming.

FREE C Cheatsheet - Speed Up Your C Programming.

Download a 7-page free cheat sheet for easy and quick access to C Concepts, Snippets, and Syntax.

Thank you! Check you inbox and access your cheat-sheet