cplusplus.com
C++ : Forum : General C++ Programming : Confusion in instruction
 
cplusplus.com
Information
Documentation
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs


post Confusion in instruction

ahsan125 (1)
i am confused about the for loop when it is written as
for(;;)
can anybody tell me what does it mean
thanks in advance
Faldrax (324)
1
2
3
4
for(;;)
{
   //Do Something
}

This is a loop which will run for ever, and is typically used where the code inside the loop include a brake statement on some specific condition to force exit from the loop.
It is the same as
1
2
3
4
while(true)
{
   //do something
}
xabnu (72)
Are you familiar with for() loops in general?

http://www.cplusplus.com/doc/tutorial/control.html

for(;;) would just mean nothing is initialised before looping, no truth is checked, and nothing is 'incremented'. Incremented in quotes, because the language only cares that this is an expression, not what it does.
Last edited on
Topic archived. No new replies allowed.