Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between for(;;) and while(1)? [duplicate]

Possible Duplicate:
Is “for(;;)” faster than “while (TRUE)”? If not, why do people use it?

I was wondering what is the difference between for(;;) and while(1) when both perform same function? Will there be any difference of speed of compilation

like image 246
abhinav Avatar asked Nov 27 '22 00:11

abhinav


2 Answers

The difference with these is that many compilers will warn about while(true) ("constant expression used as loop expression"), while none I know of warn about for(;;).

They should generate the same code, though.

like image 182
sbi Avatar answered Dec 05 '22 04:12

sbi


no functional difference at all, just a matter of taste.

like image 40
Evan Teran Avatar answered Dec 05 '22 03:12

Evan Teran