Results 1 to 5 of 5

Thread: Problem of infinite loop in C

  1. #1
    Join Date
    Apr 2009
    Posts
    47

    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.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: Problem of infinite loop in C

    In your scanf "% ld" is not there and why do you put it instead of "% id"?

  3. #3
    Join Date
    May 2008
    Posts
    2,297

    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.

  4. #4
    Join Date
    Apr 2009
    Posts
    47

    Re: Problem of infinite loop in C

    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 ...

  5. #5
    Dirk321 Guest

    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

Similar Threads

  1. Infinite Loop Fix moniter issue
    By Romany in forum Monitor & Video Cards
    Replies: 5
    Last Post: 02-04-2010, 10:39 AM
  2. Facebook Infinite Loop after Login
    By Chitamacha in forum Technology & Internet
    Replies: 5
    Last Post: 02-04-2010, 10:04 AM
  3. Infinite loop in bash
    By Maya Angelou in forum Software Development
    Replies: 5
    Last Post: 30-03-2010, 01:51 PM
  4. Is it possible to terminate an infinite loop?
    By Sheru in forum Software Development
    Replies: 2
    Last Post: 29-05-2009, 02:09 PM
  5. Infinite shutdown loop with vista
    By suseman in forum Operating Systems
    Replies: 3
    Last Post: 18-05-2009, 03:38 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,288,796.87896 seconds with 17 queries