IGNORE: Loops

Hi guys. Just wondering if there is any way of getting loops like 'if' and 'while' to repeat themselves when they are contained within a 'for' loop. I have found they tend to only loop for the first run through of the 'for' and not any of the repeats. Any help would be much appreciated.
Last edited on
Nested loops are not a problem. You may want to note that the if statement is not a loop.
I'm not quite clear what you mean. If code runs once, then it's probably just a block and not a loop.

Can you describe what you want using psuedo code. Thanks.
Sorry guys worked it out. Cheers for the help anyway.
closed account (z05DSL3A)
Without seeing code it is hard to say for certain but it sounds like you are not resetting the guards on the embedded while loops. Could that be your problem?

1
2
3
4
5
6
7
8
9
10
11
int x =0;
for(int i =0;i <10; ++i)
{
    // If x is not rest here the while loop will only run once.
    while(x < 10)
    {
        std:cout << "+";
        ++x;
    }
    std::cout <<std:endl;
}


Edit: oh well :0)
Last edited on
Topic archived. No new replies allowed.