Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hello Friends, can anybody explain me what is the error in this procedure of compiling and executing a c++ program file. enter image description here compiling and executing

share|improve this question
    
OFF TOPIC ... What terminal window are you using? – Phorce Oct 29 '15 at 11:03

If you type
g++ progname.cpp

then it will create a file named a.out which will be the file you want to use in order to run the program.

But if you wanna make a file with the name you want then -

g++ -o desiredname progfile.cpp

now this will create a file with whatever name you give
and run it using

./filename

share|improve this answer

If you haven't specified the name of the executable to produce with -o NAME, it will be called a.out, rather than the same name as the source file.

So either do:

g++ program.cpp -o program
./program

or

g++ program.cpp
./a.out
share|improve this answer
    
command for executing the a.out file? – grv.giit Jan 4 '13 at 15:01
    
thanks this solved my issue!! – grv.giit Jan 4 '13 at 15:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.