Code:
#include <stdio.h>
int main(){
int *ptr, a[5] = {0,0,0,0,0};
ptr = a; // ptr points to a
*ptr += 4; // Increase the value which ptr points to by 4, in this case a[0]+4
*(++ptr) += 5; // This should increment a[1] by 5... notice the use of () and ++
printf("a[0]= %d\n", a[0]);
printf("a[1]= %d\n", a[1]);
return 0;
}
Output:
Code:
$ gcc test.c
$ ~/a.out
a[0]= 4
a[1]= 5
edit:
May not be needed to use () but I like to because in longer expressions things can get very complicated and C's order of operation isn't always clear.