Write And Run C (C++) Program In Visual Studio 2010/ 2012 / 2013

First open Visual Studio. Then, go to File --> New --> Project, as shown below.



Once we click on Project, a new window will open. In that, go to Visual C++ Project Templates in left side and if you have found Win 32 section that would be fine; otherwise go to Extensibility --> select Install Visual Studio extensibility for Visual C++ and click OK to install C++ extensions in Visual Studio, as shown below,



Once we click OK button, it will install Visual C++ extension in our Visual Studio. Now, re-open Visual Studio and you will find Win32 option in Visual C++. Now, select Win32 Console Application --> Give name to Application and click OK.



Once we click OK button, it will show Win32 Application wizard. In that, click Next to continue, as shown below.



In next step, make sure that Console Application selected and select Empty project. Click Finish.



Now, right click on your project. Select Add --> New Item, as shown below.



Now, a new dialog will open. In that, select C++ file and give name to that file. Here, we will see file name with .cpp extension we need to change that extension to .c and click OK like as shown below,



Now, open file and write the code as shown below, 
  1. #include<stdio.h>  
  2. #include<conio.h>  
  3. void main()  
  4. {  
  5. printf("Running C from Visual Studio");  
  6. getch();  
  7. }  
In case you are getting any error for “getch()”, please change that one to “_getch()”. Now, we will run the program. For that, just click F5 button or build the application directly from Visual Studio. We will get the output, as shown below.

 
X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now