Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does for(;;) mean?

Tags:

c

I am confused by the for(;;) construct. I think it is a form of shorthand for an unlimited for loop but I can't be sure.

Here is the code:

for(;;)
{
    //whatever statements
}
like image 951
A.Smith Avatar asked Dec 04 '22 06:12

A.Smith


1 Answers

Your guess is correct; it's an infinite loop.* This is a common C idiom, although many people (including me) believe the following to be less cryptic:

while (1) { whatever statements; }


* It's infinite assuming there are no break/return/etc. statements inside the loop body.
like image 112
Oliver Charlesworth Avatar answered Dec 18 '22 04:12

Oliver Charlesworth