Notice the following program:
(I'm using Microsoft Visual Studios to compile)Code:#include <iostream> using namespace std; int main(){ for (int i = 0; i < 5; i++) { bool variable; if (i == 0) variable = true; if (variable) cout << "variable is true\n"; else cout << "variable is false\n"; } cin.get(); return 0; }
Here, when I try to compile the program, I get a Debug error (attached below).
Now if I click on the "ignore" (which I would have to do 5 times, one for every time the compiler reaches the if statement), I get the desired output which is "variable is true", 5 times.
So technically the program is working but why do I get this debug error? What's an alternative and or how do I stop this kind of response and does it have a purpose?
Thanks for reading, Cheers!