Programming in C

If you're using Linux, you're almost certainly going to be using the gcc compiler to compile your C programs. Assuming that you have a source file hello.c with the contents:

#include <stdio.h>

int main ()
	printf("Hello, world.\n") ;
you can compile and run it in a few different ways.

First, you can compile it with:

$ gcc hello.c
which should leave the resulting executable in the default file a.out.

As an alternative, you can specify the name of the output file at compile time with:

$ gcc hello.c -o hello

Finally, you can use the make utility, which can be told to make a given executable and will decide on its own how to do that and which compiler to invoke:

$ make hello


If you're new to C programming in Linux, please do not start your programming career by putting your first test file in a file called test.c. This will, by default, create the corresponding executable named test, which will clash with the standard Linux test command.

In short, try to avoid creating executables that have the same name as existing commands.