Saturday, December 21, 2013

How to Compile C and C++ Programs on Windows with Visual Studio

Are you bored with the Turbo C and Turbo C++ compilers to run/execute your C and C++ programs on your Windows Computer? Then this post is for you.In this post we will show you How to compile your C and C++ programs with Visual Studio 2012 and Code::Blocks
compile+c+and+c++

Compiling the C with Visual Studio 2012 on Windows:

First get the Visual studio from here (Official Link) (We recommend you to download the ISO copy).
u After Downloading the Visual Studio from Microsoft, Run the installation and wait for some time to complete installation( this takes some time to install).
After completing the Installation On your computer "Run Visual Studio 2012"
As soon as You start visual Studio, You will be presented with Visual Studio Start Screen.
New+Progect+1
  • Click on New Project.
  • And now click on Visual C++ and Select "Win32 Console Application", and Hit on OK.
  • In next Window click on "Finish" button.
New+Project+visual+studio+2
  • Now You will be presented with your workplace where you can starting writing your code.
  • By default Visual Studio adds the stdafx.h library and some default code. You can overwrite it and write your own code.And there is no need to add the conio.h header file to your code.
  • After completion of writing your code don't forget to add the system("pasue"); before return statement on your code.
By default your visual studio complies your code with C++ compiler which will give you so many errors on your C code, So in-order to compile your code with C compiler Hit on "Project Menu" (Alt+P) 
properties

and Select the "Console Application Properties" (Alt+F7). 
  • Now Hit on C/C++ and select "Advanced"
  • Now In the Right side menu select "Compile As" and choose "Compile As C code" and click on Ok to save the settings,
  • Now Hit on "Local Windows Debugger" to run your code!.

complie+as

Compiling C++ with Visual Studio 2012:

  • Compiling C++ on visual studio 2012 is much easier than compiling C code.
  • Click on New Project.
  • And now click on Visual C++ and Select "Win32 Console Application", and Hit on OK.
  • In next Window click on "Finish" button.
Now You will be presented with your workplace where you can starting writing your code.
Before writing the code Don't forget to add this code After link-section.
using namespace std;


And add this code with after completion of writing your code

system("pause");
and hit on Local Windows Debugger to compile your code! :-)

2.Compiling C and C++ on Code::Blocks

Code Blocks is one of the Best free and open source, cross-platform IDE which supports multiple compilers including GCC and Visual C++. It is developed in C++ using wxWidgets as the GUI toolkits.
Start+here+-+CodeBlocks+12.11

Compiling C and C++ on Code::Blocks is made so simple with Code Blocks.
Get the Code::Blocks from Here

Note Before Downloading the Binaries from Code::Blocks You need to know the slight difference in the packages available on Code::Blocks for Download
Image

You need to download the 3rd one if you have Admin rights on your computer and 4th one if you don't have admin rights to install on your Windows Computer.
After Downloading the right package for your run the installation And Launch Code::Blocks
  • Hit on File (Alt+F) and select New-->>File
  • Now here you will be able to select the type of source files.
  • Select C/C++ source file
  • and continue to your work place after saving the file and start coding!
  • To compile click on Run Button :-)

- by Computer Hoax

0 comments:

Post a Comment