0% found this document useful (0 votes)
210 views

Microsoft Visual C++ 2010

The document describes two methods for writing and compiling C programs using Microsoft Visual C++ 2010 Express Edition: using the command line or using the integrated development environment (IDE). It provides step-by-step instructions for compiling and running programs with both methods. Using the command line is simpler but the IDE allows for easier writing and formatting of code.

Uploaded by

jcastillo3
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
210 views

Microsoft Visual C++ 2010

The document describes two methods for writing and compiling C programs using Microsoft Visual C++ 2010 Express Edition: using the command line or using the integrated development environment (IDE). It provides step-by-step instructions for compiling and running programs with both methods. Using the command line is simpler but the IDE allows for easier writing and formatting of code.

Uploaded by

jcastillo3
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Writing and Compiling C Program using Microsoft Visual C++ 2010 Expre...

http://technozeal.wordpress.com/2011/01/19/writing-and-compiling-c-pr...

TechnoZeal
We have moved. Visit h p://www.ZealforTechnology.com

Writing and Compiling C Program using Microsoft Visual C++ 2010 Express Edition
There are two methods to write and compile a C program in Visual C++ 2010. You can compile a C program using command line or you can compile a C program using the Integrated Development Environment (IDE) from Microsoft Visual C++.

Using Command Line to Compile C Program


1. Select [Start >> All Programs >> Microsoft Visual C++ 2010 Express Edition >> Visual Studio Tools >> Visual Studio 2010 Command Prompt]. Run with administrator privileges. 2. Once you are in the command line, you can use any editor such as edit to write a C program. C:> edit myprogram.c 3. After wri en the program, to compile it, issue the command cl C:> cl myprogram.c 4. During the compilation and linking, myprogram.obj and myprogram.exe will be created.To run the program: C:> myprogram

Using Visual C++ 2010 IDE


1. Create an empty project by select [File >> New >> Project]. Select [General >> Empty Project] and type in the project name. Alternatively, you can select [File >> New >> Project], follow by [Win32 >> Win32 Console Application]. Type in the project name.

1 of 4

7/7/2012 9:46 AM

Writing and Compiling C Program using Microsoft Visual C++ 2010 Expre...

http://technozeal.wordpress.com/2011/01/19/writing-and-compiling-c-pr...

2. If you use Win32 Console Application, you can skip this step. Under [Solution Explorer], right click the project name, and select [Properties]. Select [Conguration Properties >> Linker >> System]. Under [SubSystem], select [Console (/SUBSYSTEM:CONSOLE)]. 3. Under [Solution Explorer, Source File], right-click and select [Add >> New Item]. 4. Under Code, Select C++ File (.cpp), however, when you type in the name use a program name with extension .c, such as myprog.c and click [Add]. 5. You can proceed to type your C program. Click [Save] icon to save your le. 6. To compile the program, under [Solution Explorer, Source File], right click the source le and select [Compile or (Ctrl+F7)]. 7. Please note that you cannot run the program until you have build solution. 8. To build solution select [Debug >> Build Solution or (F7)] 9. To run the program without debugging, select [Debug >> Start without debugging or (Ctrl+F5)]. (Note: If you do not have this option, you need to add the command manually under Tools >> Customize. You may add a menu option or a bu on in the Debug toolbar.) 10. For any runtime error, you can debug the program as follows; Select [Debug >> Start debugging (F5)]. 11. Please note that during debugging, the program will show and close the console display immediately. 12. To see the console display, you must run without debugging.

Note:
The problem using Visual Studio is that many les will be created even for a very simple program. All les are created inside the project folder. Under the project name of your program, the source code and object le is located at sub folder similar to your project name, the executable le is under sub folder <Debug>. It is simpler to use the command line to compile and run a C program, however, you could use the IDE for writing a properly forma ed C program.

2 of 4

7/7/2012 9:46 AM

Writing and Compiling C Program using Microsoft Visual C++ 2010 Expre...

http://technozeal.wordpress.com/2011/01/19/writing-and-compiling-c-pr...

ADVERTISEMENT share Like Us On Facebook Share On Twitter Share on LinkedIn Send To Friend http://nib.ly/22oq

This entry was posted on Wednesday, January 19th, 2011 at 09:55 and is led under Programming, Software Development. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

12 Responses to Writing and Compiling C Program using Microsoft Visual C++ 2010 Express Edition
1. zia says: July 28, 2011 at 07:44 i unable see console with both start without debugging n start debugging 2. technozeal says: July 28, 2011 at 16:45 If you create an empty project and add a c program separately, you need to perform step 2 under Using Visual C++ 2010 IDE If you create a Win32 Console Application, you need to remove any source le that contains extension .cpp since these are c++ les. Add an item under the source folder, select C++ Application but when you type the le name make sure that the le has a .c extension. (Example: sampleprogram.c) To see the console you need to use start without debugging. 3. Patrick says: October 3, 2011 at 00:57 Thanks! It was helpful for the using the IDE section; pre y much conrming what I thought you did. 4. Anonymous says: October 9, 2011 at 10:06 Very useful info! Thank you. 5. Anonymous says: October 20, 2011 at 15:12 Excellent article. Now the tricky one how do you create a C DLL and then call it from your C

3 of 4

7/7/2012 9:46 AM

Writing and Compiling C Program using Microsoft Visual C++ 2010 Expre...

http://technozeal.wordpress.com/2011/01/19/writing-and-compiling-c-pr...

program? I have an old C game with a library le Im trying to gure out how to get into Vis C++ Sco technozeal says: October 21, 2011 at 00:36 Here is the link on using DLL with Visual Studio 2010 . Please check out the link Walkthrough: Creating and Using a Dynamic Link Library (C++). Although the procedure is related to C++, but I believe you can use your C DLL in a similar way. 6. nonlinearly says: February 21, 2012 at 17:19 Very usefull but when I have my own header (.h) les where can I put them and how can I embed them to be recognized? I add them in the solution explorer, header les but nothing when I compile the .c le it throws an error about missing header les technozeal says: February 22, 2012 at 13:57 Try to place the headers le in the project directory. Otherwise use the full path such as #include x:\fullpath.h 7. Ma says: February 28, 2012 at 21:28 Hello, I follow the steps exactly as shown, but for some reason i am ge ing the below error. The CL.exe is refusing to compile my .c les.i do not get this error in VS2008 however. Error 1 error MSB6006: CL.exe exited with code -1073741819. Any help would be appreciated. 8. Anonymous says: April 17, 2012 at 08:03 thanq u very much 9. Steve says: June 6, 2012 at 14:21 Using VS 2010 for small C programs is like using the USAs entire nuclear arsenal to kill a fruity! technozeal says: June 6, 2012 at 14:51 Agree. But VS2010 is readily available.

Theme: Contempt by Vault9. Blog at WordPress.com.

4 of 4

7/7/2012 9:46 AM

You might also like