Your best option is to use one Debugger.
With a Debugger you can run the program line by line, you can inspect the value of variables before and after each instruction or function, you can change the value of variables dynamically, ..., ...
Each compiler has its own specific Debugger. Many Ides integrate the Debugger into the development environment in a natural way; if you use IDE the use of the Debugger may not be so natural but it is perfectly reasonable.
Another shape you’ve got printf
are within the program to see what is happening to one or more variables
for (i = 0; i < 10000; i++) {
fprintf(stderr, "DEBUGGING: i = %d; j = %d; x = %f\n", i, j, x);
/* resto do loop */
}
Have you tried using a
IDE
to debug for real?– Maicon Carraro
What tools do you write and compile the programs with? In addition to the Ides there are also "debuggers" apart as the
gdb
. Normally, you can use "breakpoints" to make the "Debugger" stop on a line of code, and then go step by step.– njsg