Doing an "if" only once

I'm trying to only access the if statement for the first print-out and the rest of the print-outs will be within the else statement (this whole thing is within a while loop). How can I go about doing this? Whenever it passes through, the bool n is always true, even if I change it to false within the if statement.

1
2
3
4
5
6
7
8
9
10
11
12
bool n;
if(n == true)
{
 cout << start;
 n = false;
 k = 0;
}
else
{
 cout << ", " << start;
 k = 0;
}
you should declare bool n = true outside of your loop. that way, when you put it to false, it will stay false (because it won't get declared again as true when it passes through in your loop)
Last edited on
Topic archived. No new replies allowed.