Always compile with the
-Wall
switch.
As matter of fact
GCC
warns on
Quote:
p=&a+2;
That shoud be instead
p = a + 2;
Try
#include <stdio.h>
int main()
{
int a[3]={1,2,3};
int *p;
p=(a+2);
*p=50;
int n=0;
for (n=0; n<3; ++n)
printf("at address %p value is %d\n", (a+n), *(a+n));
return 0;
}