From your screen-shot - you appear to still be in your home directory. If you have moved the file
function.c
into another directory, then you either need to use the
cd
command to move into the directory containing your C file and then run your
gcc
command again - OR run
gcc
from your home directory and pass the full path to the C file.
e.g.
If you created a sub-directory called
sub-dir
and you moved the C file into
sub-dir
using a command like
mv function.c ./sub-dir
.
Then in order to compile
function.c
- you can do this:
Bash:
cd sub-dir
gcc function.c
In the above - the
cd
command moves us into the directory called
sub-dir
, then we invoke
gcc
which will compile your file and because you haven't specified a name for the output file, gcc will produce a file called
a.out
in
sub-dir
- or it might produce some error messages if you have any syntactical problems with your C file!
OR the other option - From inside your home directory, you could do this:
That tells
gcc
to compile the file
function.c
which is in
sub-dir
and will produce an executable file called
a.out
in your home directory.
Also, if you use
gcc
's
-o
option - you can specify the path/file-name for the output file produced by
gcc
.
e.g.
Bash:
gcc function.c -ofunction
Above tells
gcc
to create an executable in the current working directory called
function
.
There are a plethora of other options that can be used with
gcc
.