Wednesday, 25 May 2016

How to Compile & Execute C++ Program: by using command prompt


Compile & Execute C++ Program:
Y0u can do it easily if u want to do it. So attention!
Let's look at how to save the file, compile and run the program. Please follow the steps given below:

Open a text editor and add the code as above.

Save the file as: hello.cpp

Open a command prompt and go to the directory where you saved the file.

Type 'g++ hello.cpp ' and press enter to compile your code. If there are no errors in your code the command prompt will take you to the next line and would generate a.out executable file.

Now, type ' a.out' to run your program.

You will be able to see ' Hello World ' printed on the window.

$ g++ hello.cpp
$ ./a.out
Hello World
Make sure that g++ is in your path and that you are running it in the directory containing file hello.cpp.
Thankx a lot!!

No comments:

Post a Comment