You need to put a
./ in front of
a.out in order to execute that:
When you type the name of a program such as
a.out the system looks
for the file in your PATH. On my system, PATH is set to
Yours is probably similar. To check, enter
echo $PATH in a
The system looks through these directories in the order given and if
it can't find the program produces a
command not found error.
Prepending the command with
./ effectively says "forget about the
PATH, I want you to look only in the current directory".
Similarly you can tell the system to look in only another specific
location by prepending the command with a relative or absolute path
./Debug/hello : "look for
hello in the Debug subdirectory of my
/bin/ls : "look for
ls in the directory
By default, the current directory is not in the path because it's
considered a security risk. See Why is . not in the path by
default? on Superuser for why.
It's possible to add the current directory to your PATH, but for the
reasons given in the linked question, I would not recommend it.
I'm not sure why the answer said not to change your PATH, since the answer on SuperUser said that this was a "very lame and useless anti-virus measure, and nothing stops you from adding dot to the path yourself."