Issues with a.out command

Hi,

I hope someone can help me as I've spent the last 2 days trawling the internet for a solution but to no avail.
I am very much a beginner and starting out on my C++ coding education by following online tutorials. I've already overcome a few obstacles by searching online but can't find a solution to this problem or explanation.

So I installed MinGW and all of its relevant elements on my Windows 8. I create the usual simple code to print the words "Hello World" which is one of the simplest tasks I know.

I created the helloworld.cpp file using the g++ command and then the next instruction is to type a.out to execute the a.exe file that was created but when I type "a.out" in the correct directory it says:

"a.out is not recognized as an internal or external command, operable program or batch file"

Searching online, I tried everything that people suggested; typing ./a.out , editing path environment variables etc but nothing seems to work. (I also get a message saying "." is not recognized as an internal or external command, operable program or batch file when I type ./a.out)
I then today accidentally typed "a,out" with a comma instead of full stop(period) and it printed "Hello World" in my command prompt.

So my questions are;

- why doesn't a.out command work? Do i need to fix this?
- why is "." not recognized when I type ./a.out?
- why did a,out print Hello World on my command prompt?

I'd be grateful for anyone's input to help me resolve this issue and understand why it has occurred so that I can move forward(it's very frustrating).

Thank you for your time in advance,

Mitch

 
  a.out
a.out is the default name of the executable file created using g++ on *nix.

In windows, using MinGW, the default name is a.exe

When you've run the compiler to generate your program, list the files and you will see the new executable file. That's the file you should run. You run it by typing in its name. If it's named a.exe , then type "a.exe".

You can specify the name of the generated file yourself with the g++ option "-o nameOfOutputFile"

Last edited on
In addition,
- why is "." not recognized when I type ./a.out?
- why did a,out print Hello World on my command prompt?
./a.out is how a program is run in Linux.
a,out is treated as a out to Windows cmd. As in, it runs the program called "a" (the .exe extension is optional) with one parameter "out". That's why it worked.
Repeater - Thanks very much. I knew the file was a .exe file but as this is my first foray into programming, i didn't want to not use or understand the .out extension if it was going to be necessary for me moving forward.

Ganado - Thanks for your explanation for those other queries I had. I always like to know why things are happening.

Thanks to both! Highly recommended answers and service to this lowly noob :)
Topic archived. No new replies allowed.