int main() {
int y = 8;
int x = 4;
for (int i = 0; i < 4; i++) {
if (x == 4) {
if (y == 7) {
break;
}
}
cout << "hey";
y -= 1;
}
}
The above code is code I wrote to test break
in VS code. It's really weird because I got different behaviors in VS code and VS.
In VS studio, break
works as expected: the first run, y != 7
so we don't break and we print out "hey"
. Then, y == 7
and we break the loop, so we end up with just 1 "hey"
. When I copy pasted this code into VS code on the other hand, break
literally does nothing. I have no idea why.
What could be the reason for this?