Problem of infinite loop in C
Here I have my loop:
Code:
FILE * file = NULL;
fopen ( "file.txt", "a");
number_centre long;
long l = 0;
scanf ( "% id", & number_centre);
do
(
l + +;
fprintf (file, "centre_% i.visble = false \ n", l);
) While (l! = number_centre);
and i realize that I am getting an infinite loop.
Re: Problem of infinite loop in C
In your scanf "% ld" is not there and why do you put it instead of "% id"?
Re: Problem of infinite loop in C
Code:
FILE * file = NULL;
fopen ( "file.txt", "a");
This is incomplete, read your course files.
As mentioned above the function declaration for a long is %ld and not %i.
Re: Problem of infinite loop in C
Quote:
the file is missing because of the fclose or check if the file is open
but I have to set it before and then for the "% i" I tried to replace and I repeat it but does not change ...
Re: Problem of infinite loop in C
Hi Firon,
To solve your program use Turbo C++ 3.0 IDE and trace your program by using functional key F7 and use add watch also. Then you can identify the problem very easily