Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: inl1ner on May 28, 2014, 10:44:14 pm
-
Hi All,
I use CB 13:12 rev 9501 Build : Dec 27 2013 , 12:58:38 - wx2.8.12 (Windows, unicode) - 32 bits , SDK version 1.19.0 .
In a small project of about 500 lines of C code hits me the strange problem that the result is displayed entirely correct
in a console window in debug mode while in the run mode ( F11) the results are wrong.
The point is that a linked list of students with matriculation number, first name and last name is to create and is then
written with fprintf in a simple text file. Then the list is sorted by first name, also written to a file and then the same
with a sort by last name.
Finally, the list will be cleared from memory and read the file again sorted by enrollment number with fscanf.
When I debug the whole game with some breakpoints and check the list in the Watch Window in each of these cycles,
everything looks great and also the content of the stored files is correct. As soon as I run the code without the debugger
with Build and Run, the two sorts did not work and both by name sorted lists look exactly as the sorted list by matriculation
number. The three files created in accordance with the display of the console.
Can anyone give me a hint what causes this discrepancy between dubug and run mode?
Are there settings for the debugger that affect the runtime behavior (other than the time itself) :...
Regards
inl1ner
-
In a small project of about 500 lines of C code hits me the strange problem that the result is displayed entirely correct
in a console window in debug mode while in the run mode ( F11) the results are wrong.
99.99% you have uninitialized memory/variables somewhere. Or other similar memory problems.
Find a tool that checks for such problem or inspect you program carefully.
If you're using threads or some for of concurrency then you probably have a race somewhere.
p.s. this is not a C::B question...but a general programming one.
-
@oBFusCATed
many thanks for your answer.
After all, did you busy with my problem. Ultimately, it was a mistake to have caused my almost non-existent C-skills, namely incorrect transfer of parameters to the function call. The sort was in fact not go through, but stopped immediately at the beginning because of the NULL pointer again, but why it was different when debugging ...
greetings
inl1ner
-
Sometimes there are differences in the allocators, stack behaviour, etc that masks such problems.
-
I agree that this entry is closed.
Regards
inl1ner