Thread: Writing forever loops - using for(;;) or while(1)?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    98

    Writing forever loops - using for(;;) or while(1)?

    Some people prefer using 'for (;;)', instead of 'while (1)', to write a loop that loops forever. Why?
    Code:
    for (;;) {
      DOSTUFF;
      if (...) exit(0);
    }
    Code:
    while (1) {
      DOSTUFF;
      if (...) exit(0);
    }
    Why is for(;;) better?
    Last edited by Hammer; 07-13-2005 at 04:22 PM. Reason: Disabled smilies to make it more readable [Hammer]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Writing encrypted value to file.
    By mkthnx001 in forum C++ Programming
    Replies: 13
    Last Post: 05-25-2009, 12:42 PM
  2. Optimize file writing
    By Opariti in forum Windows Programming
    Replies: 7
    Last Post: 10-23-2008, 01:32 PM
  3. Replies: 2
    Last Post: 05-20-2008, 08:57 AM
  4. writing to a binary file
    By Inver28 in forum C Programming
    Replies: 4
    Last Post: 03-02-2008, 02:36 AM
  5. for loops in C
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 10-15-2001, 05:09 PM