C - is it possible to decrement the max value of a for loop from within the for loop?
- by hatorade
for example:
void decrement(int counter) {
counter--;
}
int counter = 20;
for (int i = 0; i < counter; i++) {
for (int j = 0; j < counter, j++) {
decrement(counter);
}
}
ideally, what i'd like to see is the counter var being decremented every time the for loop is run, so that it runs fewer than 20 iterations. but gdb shows that within decrement() counter is decremented, but that going back to the for loop counter actually stays the same.