You will have more luck with finding the exact point in your code that's causing issues if you run your program within gdb (GNU Debugger)

Try executing your code like this:

gdb <name-of-your-compiled-application>

This will open a little shell. In the shell type "run" and hit enter (don't type the quotes). This will start the application and run through until you hit your segfault. At this point running "bt" and enter will give you a backtrace showing where in your app the segfault occurred.