how to run debugging on c program

Can someone help me debug a c program I am running? It gives me segmentation fault.

I want to turn on debugging. Can some one give the command to turn it on?

Below is the error I get:

Segmentation Fault (core dumped)

You need to compile and link all its bits with the -g switch, and without the -fomit-frame-pointer switch. Actually, you don't need to recompile all of it, just the bits you're interested in debugging.

Most C Proggramers and users use gdb for debugging the codes, you may try it out. Also another tool you might find useful for debugging is `strace', which displays the system calls that a process makes. It has a multiplicity of other uses too, including figuring out what pathnames were compiled into binaries that you don't have the source for, exacerbating race conditions in programs that you suspect contain them, and generally learning how things work. The latest version of strace (currently 3.0.8) can be found at ftp://ftp.std.com/pub/jrs/.

1 . At first , you should re-compile your prograem with -g option .
2 . run it , if it has produced a core file , you can use dbx(debugger) to find where does the programe coredump.

type the command "dbx programe-name core" and when you see "dbx>" prompt ,you type "where" command .In most case, you can see the stack

You can do the same thing with gdb.
Compile with -g option, run
gdb a.out -core ./core
and the command is "bt" (back trace). This gives you the stack in gdb.