If you ever
wished to run a c/c++ program in visual studio then your wish can become
true.Here I will tell you step by step process of compiling and running c/c++
programs in visual studio.
But before that I would like to discuss some
advantages of writing a c/c++ program in visual studio.
1.Main
advantage is that using visual studio you can write a c/c++ program in window 7
in which most of the other compiler like turbo c does not work.
2.It also
supports 64 bit window.
3.If you are
already using visual studio then why not to use it.
4.We can
create multiple c/c++ files under single project.
Now let’s
come on the main topic ‘steps for writing c/c++ program inb visual studio”.
1.Goto File
=>New => Project.
Goto Other Languages =>Visual
C++=>Win32
Now in
template select win32 console application.
3.Enter the
name of the project ,specify a location for your project directory and click ok.
4.Now win32
application wizard will open.Click next for application setting.In application
setting
a)uncheck precompiled header.
b)check empty project.
c)check console application if
unchecked.
d)click finsh.
5.A new
project will be created. Now in solution explorer right click on source file
and goto add=>new item.
6.Add new
item window will open.In this window select c++(.cpp).
7.Enter the
name of file and click add.
8.A c++ file
will be created.Now you want a c file then rename this file to *.c.
The default here will be
a file with a *.cpp extension (for a C++ file). After creating the file, save
it as a *.c file.
Steps to compile and
run:
1.
Press the green play
button in toolbar.
2.
By default, you will be
running in debug mode and it will run your code and bring up the command
window.
To prevent the command window from closing as soon as the program finishes execution, add the following line to the end of your main function:
getchar();
This library function waits for any input key, and will therefore keep your console window open until a key is pressed.
To prevent the command window from closing as soon as the program finishes execution, add the following line to the end of your main function:
getchar();
This library function waits for any input key, and will therefore keep your console window open until a key is pressed.
Hope this post helped
you! Join us on Facebook.