# Thread: Weird Problem With Pointer

1. ## Weird Problem With Pointer

Hey i have a program and i overloaded the + operator and for this one set of numbers -888+-112 i get the wrong number, i ran GDB and this is what i get maybe someone can see why c is getting set to the weird number of 134489 when temp is showing its 0.

Code:
```538             if(count == c.numDigits)
(gdb) print count
\$11 = 3
(gdb) print c.numDigits
\$12 = 3
(gdb)
\$13 = 3
(gdb) n
541                 temp = c.digits;
(gdb) print temp
\$14 = (int *) 0xb7f1221f
(gdb) print *temp
\$15 = -273227
(gdb) print c
\$16 = (BigInt &) @0xbfe13498: {digits = 0x80502a0, numDigits = 3,
positive = false}
(gdb) print c.digits[2]
\$17 = 0
(gdb) print c.digits[1]
\$18 = 0
(gdb) print c.digits[0]
\$19 = 0
(gdb)
\$20 = 0
(gdb) n
544                 c.numDigits++;
(gdb) print *temp
\$21 = 0
(gdb) n
547                 c.digits = new int [c.numDigits];
(gdb) n
550                 for(i = 1; i<=c.numDigits; i++)
(gdb) print c
\$22 = (BigInt &) @0xbfe13498: {digits = 0x8050008, numDigits = 4,
positive = false}
(gdb) n
552                     c.digits[c.numDigits-i] = temp[c.numDigits-i];
(gdb)
550                 for(i = 1; i<=c.numDigits; i++)
(gdb) print c.digits[3]
\$23 = 134489```

2. >c.digits[c.numDigits-i] = temp[c.numDigits-i];
You might try printing temp[3], temp[2], temp[1], and temp[0]. I would expect temp[0] would be equal to 0, because *temp is 0.

3. what do u mean? i temp is equal to 0 but yet c.digits[3] is 134489 for some reason. I thought i could get rid of that by making everything equal to 0 in c.digits.

4. >i temp is equal to 0
It looks like temp is actually an array consisting of numDigits elements though, because I see this:
Code:
`temp[c.numDigits-i]`
And if you print *temp, I think this is equivalent to temp[0], at least that's true in C++. It's hard to decipher your debug output, but it looks like you only print *temp (or temp[0]), so maybe temp[1] thru temp[3] contain something besides 0.