Mysterious c debugging problem when trying to utilize printfs

Posted by O_O on Stack Overflow See other posts from Stack Overflow or by O_O
Published on 2011-01-12T00:43:49Z Indexed on 2011/01/12 0:53 UTC
Read the original article Hit count: 143

Filed under:
|
|

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. :(

© Stack Overflow or respective owner

Related posts about c

    Related posts about debugging