Infinite Loops in C

This is a discussion on Infinite Loops in C within the C Programming forums, part of the General Programming Boards category; How to make an infinite loop in C .If I am using while for example??...

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    48

    Infinite Loops in C

    How to make an infinite loop in C .If I am using while for example??

  2. #2
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,707
    Code:
    while (1) {
       printf("forever");
    }

  3. #3
    Registered User
    Join Date
    Jul 2008
    Posts
    48
    Thanks!

  4. #4
    Registered User
    Join Date
    Jul 2008
    Posts
    48
    That perfectly worked

  5. #5
    Ugly C Lover audinue's Avatar
    Join Date
    Jun 2008
    Location
    Indonesia
    Posts
    489
    Code:
    for(;;)
    {
        printf("Alternative infinite loop.\n");
    }

  6. #6
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Code:
    Loop:
       printf( "Infinite loop with goto." );
       goto Loop;

  7. #7
    Registered User
    Join Date
    Apr 2008
    Posts
    14
    I like doing it this way:

    Code:
    #define forever while(1)
    
    forever {
            printf("loop\n");
    }

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,744
    I like doing it this way:
    I do not think it is worth the trouble though. for (;;) and while (1) are universally recognised as deliberate infinite loops.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  9. #9
    Registered User
    Join Date
    Jul 2008
    Posts
    48
    Thanks guys You are all great!! and so are your suggestions

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Infinite While Loops Question
    By hern in forum C++ Programming
    Replies: 4
    Last Post: 08-13-2005, 07:27 PM
  2. please help, infinite loops!
    By HybridM in forum C++ Programming
    Replies: 18
    Last Post: 01-14-2003, 08:27 PM
  3. i have infinite loops. why?
    By hermit in forum C Programming
    Replies: 20
    Last Post: 04-17-2002, 06:58 AM
  4. help with arrays and loops
    By jdiazj1 in forum C Programming
    Replies: 4
    Last Post: 11-24-2001, 03:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21