Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

C++ 'a.out' not recognised as a command

Hi all, 

I'm new hear and very new to coding. Just setting out on my learning journey to be honest. I'm hoping someone will be able to help. 

I've set up my C++ environment and was about to start learning and practicing, following the Tutorials Point tutorial. 

I created my first helloworld.cpp file, used g++ to convert it to an executable file and then followed the tutorials next instruction which was type 'a.out' to execute the file. When I do this, it gives me the error: "a.out is not recognized as an internal or external command, operable program or batch file"

I've typed the error into google and followed some instructions but none have helped me to fix this issue. In fact, I couldn't see any other mention of this exact error.  

I am in the correct directory and have added the bin subdirectory to the Path environment variable.

Please could somebody help? 

Thanks in advance


1 Answer
Pythonista

Having entered following command from linux terminal

$ g++ helloworld.cpp

The a.out file should be created in the current working directory if the compilation is successful. Check if a.out is created.

To execute enter following from command line

$ ./a.out

In most cases, output of your source program is displayed. However, as in your case, error message indicating a.out is not executable is appearing. See the properties of a.out and make it executable (if not already) by following command:

$ chmod +x a.out

You may require sudo privilege for this. In all probability this should work. all the best

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.