C programing

Compiling a C program with one command: gcc [-ggdb] -o program_name source.c

-o is the output option and "program_name" is the argument for the -o option

-ggdb tells gcc to add debugging information in the output executable Example: gcc -ggdb -o hello hello.c

Debugging

The GNU debugger is called like this:

gdb program_name

Some Uesful Commands:

help

l - List lines of the source code

b line_number - Place a breakpoint at line number "line_number"

run - Start running the program

next - Execute the next line and stop

step - Step over funtions and stop at the next source line

Enter - Repeat the next line


To edit a .c program: vi file name

Example: vi hello.c

Back