Hello!
Try following steps:
1) Compile your program with `-g' option:
Code:
g++ -g <your_program>.cpp
2) run `gdb a.out'
2a) in the GDB prompt type `run':
Code:
(gdb) run <put_program_options_here>
2b) when GDB tell you that Segmentation Fault has occured:
Code:
Program received signal SIGSEGV, Segmentation fault.
0x0804836f in main () at <your_program>.cpp:<line_number>
<line_number>: ...
take a look at your code around <line_number> (type `l <line_num>'), check variables value with gdb command `print' (e.g. type `p my_variable'). It may be useful to look at stack (`bt' command, stands for backtrace) and to walk through the stack with `up' and `down' commands.
3) Another cool program is `valgrind'. Install it! Usage is very simple: `valgrind a.out' or `valgrind --leak-check=full a.out'
4) Post your code here.
Bye.