P
pauldepstein
I have code that looks like this:
for (int counter = 0; counter < 100; ++ counter)
{
{ static int blah = 0;
if (blah == 0)
// do something;
blah ++;
}
}
This is already legal code. My problem is that I want it to execute
the inner loop 100 times. Each time it increments counter, I want it
to do the inner loop exactly once -- once for each value of counter.
So I made the blah variable static to enforce this once-only property
(to enforce that do something was never done more than once per value
of counter). But now I expect it will only do something once in
total, not 100 somethings -- once for each value of the counter.
Any solution to what must be a standard problem.
Thank you very much for your help,
Paul Epstein
for (int counter = 0; counter < 100; ++ counter)
{
{ static int blah = 0;
if (blah == 0)
// do something;
blah ++;
}
}
This is already legal code. My problem is that I want it to execute
the inner loop 100 times. Each time it increments counter, I want it
to do the inner loop exactly once -- once for each value of counter.
So I made the blah variable static to enforce this once-only property
(to enforce that do something was never done more than once per value
of counter). But now I expect it will only do something once in
total, not 100 somethings -- once for each value of the counter.
Any solution to what must be a standard problem.
Thank you very much for your help,
Paul Epstein