When I run
$ gcc hello.c
$ ./a
Hello, World.
I don't know what ./a
exactly indicates.
What is it? What does it stand for?
If you know the meaning of it, I'd really appreciate that you would share.
When I run
$ gcc hello.c
$ ./a
Hello, World.
I don't know what ./a
exactly indicates.
What is it? What does it stand for?
If you know the meaning of it, I'd really appreciate that you would share.
./
is the current directory when using a Unix-like shell (like bash.) The name of the executable GCC produces is a.exe
.
So to run the produced executable, you need to specify the path to to it, in this case "the current directory", which is ./
, and the name of the executable, which is a.exe
. Since you can omit the .exe
when running executables on Windows, instead of ./a.exe
you can just run it with ./a
.
If you were to use the Windows command-line shell (like cmd.exe or PowerShell) you would instead just type a
, because the current directory (.\
in this case, Windows uses \
instead of /
for the directory separator character) is searched for executables by default. Unix shells do not, which is why you need ./
.
If you want to give the produced executable a different name, for example hello.exe
, you can:
gcc hello.c -o hello.exe
You would then run that with:
./hello
or:
./hello.exe
.a is the standard/default output of the compiled program, when no output name is provided.
When you've compiled C program and given no name to the output file, gcc will automatically set the output file name as a.
The file name is overwritten for the last compiled C program, when no output name is provided.
This standard is same in both Unix and Windows.
To set name for the output program, Use -o
argument followed by the output name sum_program
gcc sum_program.c -o sum_program
Depending on the library use, and other linkers, additional arguments like -o
can be added for compilation.