I'm trying to remember how to do pointer arithmetic (I haven't coded in a while). This is what I came up with.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
int main()
{
int pow, pow2, pow3;
int *dow = &pow;
pow = 1;
pow2 = 2;
pow3 = 3;
for(int i = 0; i < 3; i++)
{
std::cout << *dow << std::endl;
++dow;
}
return 0;
}
When I run this the result is:
1
1
2
After I changed it to i < 4 it displayed 3 as expected but I can't figure out why pow's value repeats at the beginning. Thank you advance.