Mysterious c debugging problem when trying to utilize printfs
- by O_O
Ok, folks. I've never encountered this before and it boggles the mind and is illogical. I have a somewhat complex loop and I want to try and see if everything is working by putting some printf statements. I look the intermediate products using printf and verify that the answer is ok. Then, when I comment out the printf to the intermediate products, the answer is WRONG. Has anyone ever encountered this? This is driving me insane and I don't see how the printfs could change an answer.... X_x If it helps, I am using a c/c++ compiler for a DSP. Thanks for any advice..
Here is a snippet...
printf("splitBackground = %d, numWindowPoints = %d\n", splitBackground, numWindowPoints);
splitBackground = splitBackground/numWindowPoints;
printf("%d ", splitBackground);
This is good but when I comment out the first line of code, it turns out to be hugely incorrect. :(