An example
Code:
#include <iostream>
using namespace std;
int main ( ) {
int i, sum = 0;
for ( i = 1 ; i <= 10 ; i++ ) {
sum += i;
#ifdef DEBUG
cout << "Debug: i=" << i << " sum=" << sum << endl;
#endif
}
cout << "Sum=" << sum << endl;
return 0;
}
To run the code normally, you would do
gcc -o prog prog.cpp
./prog
and just see the final sum.
But if it wasn't working properly, you could enable all the debugging
gcc -DDEBUG -o prog prog.cpp
./prog
Now you would see all the iterations of the loop as well.