in reply to while () vs. while (1)

It is derived from the C idiom  for (;;) where nothing in the conditional is an infinite loop.

Replies are listed 'Best First'.
Re^2: while () vs. while (1)
by ikegami (Patriarch) on Jan 22, 2011 at 00:36 UTC

    Interestingly though, C doesn't seem to allow an empty condition for while.

    $ cat a.c int main() { while () { break; } return 0; } $ gcc a.c a.c: In function ‘main’: a.c:2: error: expected expression before ‘)’ token

    It is well known to allow it for for. I read "for (;;)" as "for ever", and use it where some use while (1).

    It could very well be unintentional, but fixing it could break code at no benefit.