Join 149,474 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,867 people online right now. Registration is fast and FREE... Join Now!
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { char numc[81]; int num, oldnum = 0, i=0, booleani = 0; //bool end = false; printf("Please enter some integers followed by a zero."); while(booleani = 1/*end=false*/){ i++; gets(numc); int num = atoi(numc); if (num = 0){ booleani = 0; break;}
, right, but when i run it, the loop never stops ( never outputs, never PAUSEs). i know it's crappy, but i spent a while tweaking it to see if anything i did would make it work. so ignore the redundancies (unless they're the problem), and help me if you will. Thanks, -R
I cannot open the screen shot, anyways what happen, did you check your logic is everything cool with the values of the variables? Please explain.
bassically, the comp entered 3997696 for me and went to "PAUSE". I think my logix cool. by all reason, break; or changing booleani's value should stop the loop, but it doesn't. maybe it never gets there... hold on.
CODE
... if (numc == "0"){ booleani = 0; break;} ...
nope, still doesn't work: loop again doesn't end. -R
Opens fine for me. I wouldn't call that "freaky" though.
If I cannot open it doesn't imply that most of the members can't open the file
QUOTE(Re@p3rM4n @ 5 Feb, 2008 - 06:00 PM)
QUOTE(PennyBoki @ 5 Feb, 2008 - 05:51 PM)
I cannot open the screen shot, anyways what happen, did you check your logic is everything cool with the values of the variables? Please explain.
bassically, the comp entered 3997696 for me and went to "PAUSE". I think my logix cool. by all reason, break; or changing booleani's value should stop the loop, but it doesn't. maybe it never gets there... hold on.
CODE
... if (numc == "0"){ booleani = 0; break;} ...
nope, still doesn't work: loop again doesn't end. -R
The logic is bad because booleani is set to 0 and in the while condition is while booleani is 1? That is bad logic so the program just skips the while and goes directly to printing the value of num, which is some "garbage".
Opens fine for me. I wouldn't call that "freaky" though.
If I cannot open it doesn't imply that most of the members can't open the file
QUOTE(Re@p3rM4n @ 5 Feb, 2008 - 06:00 PM)
QUOTE(PennyBoki @ 5 Feb, 2008 - 05:51 PM)
I cannot open the screen shot, anyways what happen, did you check your logic is everything cool with the values of the variables? Please explain.
bassically, the comp entered 3997696 for me and went to "PAUSE". I think my logix cool. by all reason, break; or changing booleani's value should stop the loop, but it doesn't. maybe it never gets there... hold on.
CODE
... if (numc == "0"){ booleani = 0; break;} ...
nope, still doesn't work: loop again doesn't end. -R
The logic is bad because booleani is set to 0 and in the while condition is while booleani is 1? That is bad logic so the program just skips the while and goes directly to printing the value of num, which is some "garbage".
i just changed it. ya'know, i was going to say 'i knew it was sumfin stupid like that' except the loop is still not ending. -R
This post has been edited by Re@p3rM4n: 5 Feb, 2008 - 05:10 PM
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { char numc[81]; int num, oldnum = 0, i=0, booleani = 1; //bool end = false; printf("Please enter some integers followed by a zero."); while(booleani = 1/*end=false*/){ i++; gets(numc); int num = atoi(numc); if (numc == "0"){ booleani = 0; break;}