If I change the bold part to p1=p1+1 or p1=p1+2, the result will be correct, but there is always a error window pop up, Once I change it to p1=p1+3 or p1=p1+4 etc. the program will run properly. In another word, the number followed by "+" must be larger than 2.
By doing
p1=p1+ <insert number here>;,
you are changing the pointed-to address, thus when you do:
*p1=<insert number here (again)>
you are assigning the number to absolute garbage.
It works in the second part because all of the memory addresses in an array are in a row, whereas in the first example, there is no set variable (likely) that has its address immediately after a.
As for why it works with numbers > 2, i dunno.
QWERTYman (because my alter alter ego, DVORAKguy, is unnecesarily uncommon)
By doing
p1=p1+ <insert number here>;,
you are changing the pointed-to address, thus when you do:
*p1=<insert number here (again)>
you are assigning the number to absolute garbage.
It works in the second part because all of the memory addresses in an array are in a row, whereas in the first example, there is no set variable (likely) that has its address immediately after a.
As for why it works with numbers > 2, i dunno.