A Short Tutorial to Compiling C Code in Visual C++ 2005
Ben Hermens - hermens@eecs.oregonstate.edu
Install Visual C++ 2005 Express Edition:
Download the installer and run it from:
http://msdn.microsoft.com/vstudio/express/visualc/
It does not appear that it is necessary to install the
Platform SDK when you're just writing simple C programs.
Open the program and create a new project:
File->New->Project...
From the "Project types" tree, select "Win32".
Select the "Win32 Console Application" template.
Name the project and select a folder to save it in.
Click Ok.
In the resulting window, click "Next >".
Check the "Empty Project" box.
Click Finish.
Add files to the project:
In the Solution Explorer subwindow,
Right click on the project name and select:
- "Add -> New Item ..." to create a new file
- "Add -> Existing Item ..." to add an existing file
New Item:
From the "Categories" tree, select "Code".
- Select the "C++ File (.cpp)" template.
- Name the file: "filename.c".
-OR-
- Select the "Header file (.h)" template.
- Name the file: "filename.h".
Click "Add".
To make the compiler treat the code as C and not C++:
In the Solution Explorer subwindow,
Right click on the project name and select "Properties".
Expand the "C/C++" group of the tree.
Select "Advanced".
Change the option: "Compile As" from "C++ Code" to "C Code".
Build (compile and link) your program:
Press F7
Run the program:
Press Ctrl-F5