Sean Kennedy
Sean Kennedy

Reputation: 33

Integer doesn't have the expected value in debugger

Like any normal C++ programmer, when I type this code...

for (int m = 0; m < 3; m++){
    for (int n = 0; n < 3; n++){
        if (A[m].substr(size,location) == B[n].substr(size,location)){
            return false;
        }
    }
}

I expect the first value of m to be 0 in my iteration. (because I literally declared it as having a value of 0) However, my program was acting a tad funky, so I decided to look at it in the debugger. Interestingly, rather than having a starting value of 0, C++ decided that m should have a starting value of 32767.

Could someone explain to my why and how this could possibly happen?

Upvotes: 0

Views: 90

Answers (1)

Sean Kennedy
Sean Kennedy

Reputation: 33

Ah, templatetypedef was right. Once I stepped over to the next breakpoint its value was initialized. Thanks guys!

Upvotes: 1

Related Questions