write a lot of printf statements at various places in your code under suspicion OR use gdb (GNU code debugger) Compile code using -ggdb switch For example, g++ -ggdb -o hellowworld helloworld.cc Run your code under gdb using gdb helloworld Set a breakpoint at the location where you suspect the problem to be. Now the code has stopped the execution, you can continue step-by-step execution using a step or you can continue the execution continuously using continue or you can print the values of various variables at this stage using print var_name To find the stack trace use backtrace use quit to exit gdb [and stop to stop a program that is still under execution]