Reputation: 41
i've this code here:
for(i = openGates[0]; i < closeGates[0]; i++) {
if(str[i] == '(') {
closeGates.removeFirst();
openGates.removeAt(1);
}
}
If brace found, closeGates[0]
's value will change. Will it change the number of iterations?
Upvotes: 2
Views: 431
Reputation: 41
Apparently, no one decided to answer and I want to close this question so: yes, in C++ 'for' loop evaluates its conditions before every iteration thus the number of the iterations might change.
Upvotes: 2
Reputation: 967
Yes, the iteration-expression
is executed after every iteration of the loop.
Reference for this answer :
https://en.cppreference.com/w/cpp/language/for
Upvotes: 2