You could also use a core dumb and then examine it with gdb. To get useful information you also need to compile with the -g
flag.
Whenever you get the message
Segmantation fault (core dumped)
a core file is written into your current directory. And you can examine it with the command
gdb your_program core_file
The file contains the state of the memory when the program crashed. A core dump can be useful during the deployment of your software.
Make sure your system doesn't set the core dump file size to zero. You can change the size with ulimit -c
. Be aware that core dumps can become huge.