Why is visual studio not aware that an integer's value is changing? (debugging)

Posted by incrediman on Stack Overflow See other posts from Stack Overflow or by incrediman
Published on 2010-04-23T04:43:35Z Indexed on 2010/04/23 4:53 UTC
Read the original article Hit count: 202

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about visual-studio-2010

Related posts about debugging