Why use infinite loops?
Posted
by Moishe
on Stack Overflow
See other posts from Stack Overflow
or by Moishe
Published on 2008-10-22T01:56:18Z
Indexed on
2010/05/27
3:41 UTC
Read the original article
Hit count: 322
Another poster asked about preferred syntax for infinite loops.
A follow-up question: Why do you use infinite loops in your code? I typically see a construct like this:
for (;;) {
int scoped_variable = getSomeValue();
if (scoped_variable == some_value) {
break;
}
}
Which lets you get around not being able to see the value of scoped_variable in the for
or while
clause. What are some other uses for "infinite" loops?
© Stack Overflow or respective owner