Is using a while block to do nothing a bad thing?

Not at all – I believe you’ll find do-nothing loops like these in K&R, so that’s about as official as it gets.

It’s a matter of personal preference, but I prefer my do-nothing loops like this:

while(something());

Others prefer the semicolon to go on a separate line, to reinforce the fact that it’s a loop:

while(something())
  ;

Still others prefer to use the brackets with nothing inside, as you have done:

while(something())
{
}

It’s all valid – you’ll just have to pick the style you like and stick with it.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)