Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Empty for loop

Name: Anonymous 2009-03-14 16:40

I just came across a for(;;) while reading through MSDN on winsock.

What is the purpose of an empty for(;;) loop? Can not the exact same thing be accomplished with a while loop? Seems like tomayto-tomahto to me. If there is some significant purpose though, I'd much like to know.

Name: Anonymous 2009-03-14 16:54

>>3

At the risk of surely sounding like a newfag, no idea what HIBT means. I know how to make and use an empty for loop, but I can do the exact same thing with a while loop. I was just wondering if there was any significance in using a for(;;) in particular.

int counter = 0;

for(;;)
{
  if( something = x )
  {
     function();
     counter++;
  }

  etc....

  if( counter = 3 )
  {
     break;
  }
}

is the same as

int counter = 0;

while( counter < 3 )
{
  if( something = x )
  {
     function();
     counter++;
  }
 
  etc....
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List