It's very easy to isolate a segfault (includes sigsegv) using a debugger.
If you are developing on Unix, please run your code in a debugger.
- Compile your code with the
-g
flag. - Run your code in gdb as follows -
gdb a.out
(or name of program) - Run:
(gdb) run
- Your program will crash at your segfault. It should show you the exact line number it happens on. You may have to type
bt
orwhere
to trace it back.
In IDEs it's even easier. Usually you debug by looking for a debug symbol, often graphically represented by a bug (e.g. Eclipse). I'm not familiar with the IDE you use so perhaps if you have trouble someone could post an answer specific to that IDE.