CSC373/406: C: Compiling C programs [29/42] Previous pageContentsNext page

file:hello.c [source]
00001: #include <stdio.h>
00002: 
00003: int main()
00004: {
00005:   printf("hello, world\n");
00006: } 
00007: 

To compile a single file C program in a file named hello.c use the gcc compiler.

$ gcc hello.c -o hello

This compiles the program hello.c, links it with any standard c library routines called (e.g. i/o routines) and produces the executable file named hello.

Now run hello:

$ ./hello

Previous pageContentsNext page