I have a few simple lines of code (below). [bp] indicates a breakpoint.
for(int i=0;i<300;i++){}
int i=0;
cout<<i;
[bp] for (i=0;i<200;i++){}
When I debug this in visual studio, it tells me that i is equal to 300 on the breakpoint. Annoyingly, 0 is printed to the console. Is there any way to make it realize that two variables in different scopes can actually have the same name?
I also want to add some code to the second loop and then debug it – but when I try to do that, i is consistently shown as 300. Very annoying.
in my visual studio, looking at the debugger Locals window
NOTE! there are two i varibles in the debug output, i == 300 and i == 0
I’m thinking the reason its getting confused is a quirk/bug of the debugger where it tracks both i’s then gets confused when you hover over an i, it just returns the first i? or some such, I don’t think its semantically checking which i to show.