while(cond) // fine
for(;cond;) //fine
but when I remove the conditional part
while() //syntax compilation error
for(;;) //Infinite loop
How these loops are internally implemented ?
Or,how does compiler (parser) know that empty condition in while is error and in for as Infinite?
I didn’t find anything about this particularly, I think guys like me (who are beginner) in C might have same confusion
The standard requires that the omitted condition for
forloop is replaced by a non-zero constant:From C11 6.8.5.3: (emphasis mine)
Since there’s no such requirement for
whileloop (if the condition is omitted), I believe, it’s left to the implementation of compiler.