g++ foo.c
where foo.c
is the name of the program to be compiled. This will produce an executable in the same directory called a.out
which you can run by putting this in your terminal - ./a.out
g++ -o output foo.c
This will compile foo.c
and you can type ./output
to run the compiled code.