1
I’m new to the community, and I recently noticed in a C code, a FOR loop, with the following syntax. for(;;). Someone could explain that syntax to me. Thanks in advance.
1
I’m new to the community, and I recently noticed in a C code, a FOR loop, with the following syntax. for(;;). Someone could explain that syntax to me. Thanks in advance.
2
The for(;;) command is an infinite loop. To exit this loop you normally use the break command. Thus
for (;;)
{
...
...
if (alguma_condicao)
break; // sai do loop
...
...
}
Browser other questions tagged c for syntax
You are not signed in. Login or sign up in order to post.
Cool, thanks for answering. Very cool, this syntax of for, and very useful too. Thanks.
– Emerson Oliveira
Then mark the solution as a response.
– FourZeroFive
Excuse me, but such use of the command in this way is not legal. If you must remain in the loop until you see any conditions then use while or/while.
– anonimo
@anonimo, infinite loops are a common Pattern in C and C++...some people prefer "while (true)", others prefer "for(;)" .. , see here on page 60 of the book K&R they talking of the loop "for (;;)"
– zentrunix