C Language - For Loop that just keeps on runnin'
Hi guys,
In the code segment below is a for loop I am having some considerable difficulty with. It just keeps iterating endlessly and totally ignores the 70 times limit specified. I can't ever remember having this problem before and am absolutely Clueless. Can anyone spot the error? Code:
for ( x = 0; x < 70; x++ ) |
Quote:
Why won't print 'x' from inside the loop ? |
Just inserted the printf x idea of yours and whilst the program runs, generating an increasingly large output file, x is stuck at only 4 for some reason. Any ideas?
|
I should say I don't have access to a IDE with a nice step-through de-bugger; I've only got nano!
|
Quote:
Publish full source and compile with '-Wall -Wextra -Wformat=2' and make sure there are no warnings. |
Ok, here's the complete source. In the mean time I will try your compile options...
Code:
#include <stdio.h> |
Your compile options generated no warnings or errors.
|
Quote:
|
Thanks, Sergei, but how does that cause the loop limit to be breached? And as I say, I am not getting any warnings at all with your option string.
|
Add -O2 - this will produce the needed warning.
|
Quote:
|
Quote:
|
I get the impression you erased the \0 character terminating your string so fputs goes on printing forever because it doesn't know where to stop.
|
Quote:
it'll almost certainly be a package on your distro. or sit down and learn how to use gdb |
Quote:
|
All times are GMT -5. The time now is 04:15 AM. |