You'll probably find that the easiest way of debugging errors like this is with the use of a debugger.
As Starkey suggested, make sure that you enable debug symbols when you compile (through the -g
option to gcc).
You may find that when your program crashed with the segmentation fault that it generated a core file. You can use a debugger (eg. gdb) to open the core file and to investigate the call stack. The advantage of using the debugger is that it will (if you've enabled debug symbols) show you the line numbers within your source files, rather than just providing memory locations.
If you don't have a core file you can run your application from within gdb and then reproduce the segmentation fault.