I am learning C programming by myself, and stuck with this practice
int a[] = {5,7,9,11,13};
int *p;
int i = 2;
p = a;
*(p++) = ++i;
printf("%d %d %d %d", a[0], a[i++], *p, *(p+2));
// output: 3 11 7 11
My understanding is that
1.define an array a
and initialise it with values 5,7,9,11,13
2.define pointer p
3.define i
and initialise it with value 2
4.p points to array a
5.p[1] = 3;
- a[0] = 5, a[3] = 11, *p = p[0] = 5, *(p+2) = p[2] = 9
//output: 5 11 5 9
But they are totally wrong !
I may need detailed explanation for this.
Please help me and many thanks!