I compiled a c++ file in Unix as gcc filename.cc. It didn't give me any error. But when I type a.out next it is saying file not found or bad command. The same thing is happening when I try to compile and run a C file giving the command cc filename.c and a.out.
My guess is that you're logged in as root and the default PATH for root is NOT to include the current directory or ".". By saying ./<program_name> you're telling the shell to run the a.out in the current working directory.
You can also compile with the -o option like this:
gcc filename.c -o filename
so the output will go to filename instead of to a.out.
0
thenmozhiaAuthor Commented:
I found Jhance answer is correct. By mistake previously I rejected his anwer. Sorry for that.
Thankyou
0
thenmozhiaAuthor Commented:
o.k. and Thankyou so much.
0
Question has a verified solution.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.