User forums > Help

Is the result of "printf" and "debug watch" different?

<< < (3/4) > >>

hnust_zhangyehua:
How can i post the picture? :-[  I press the "insert images" that has no reaction. :-[

BlueHazzard:
You can add the image as attachement add the bottom, or better you use a imige hoster like https://postimage.org/ and post the link here

And please post also the debugger log in code tags

Greetings

hnust_zhangyehua:
Thanks for your picture link.
the first photo which stands for "printf window" after execute

https://postimg.org/image/h7qjtbbbf/

the second photo which stands for "debug watch" and "printf window" in the debugging, the third photo is the position of debugging.

https://postimg.org/image/7oguzunt7/6cf18042/
https://postimg.org/image/p31384ky3/dad9b28d/

Apparently, the first photo is differren from the second photo.

Greets

BlueHazzard:
Now i begin to understand:
You start your program with the debugger and it works as expected, but if you start your program without debugger it fails?

I can reproduce this. It is not a fault of the debugger, but this happens if you don't initialize a variable, like here:

--- Code: ---int a[100],b[100],z[100],i,s,F,w,x;
--- End code ---
all this variables have random values. It is possible that the debugger runs on a zeroed ram segment, and all your variables are initialized with zero, but in release mode your program runs on a random filled ram segment, so your variables are filled with random values. This leads to errors like you are receiving.


This has nothing to do with codeblocks or the debugger, but with clean programming...
The solution would be to clean up your code...

hnust_zhangyehua:
A very important problem that I forget to tell you :'(
This code runs at Visual Stdio is good, in other words, when the code run at the Visual Stdio, its result, on the "printf windows" whether  after execute or in the debugging, is same. Moreover, the result of array C in the  Visual Stdio is same as the other result when the code is debugging in the codeblocks.

Therefore, I can get a conclusion that codeblocks goes wrong :'(

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version