#include #include // point to the next int void incrP(int* p){ (*p)++; // () necessary, what happens without them? } main() { //int i int i=10; //pinter to int dp int *dp; // array A: a CONSTANT pointer to the first of a sequence of ints int A[3] = {0,1,2}; // gcc does a compile time bounds check and issues a warning // eg for int B[3] = {0,1,2,3}; // we can assign an array to a pointer dp = A; printf("dp=A; *dp=%d\n", *dp); // An array is not a pointer variable, but a pointer constant // so we cannot assign new address to A as in // A = &i; // &: address of operator, *: follow reference (dereference) operator dp = &i; printf("dp=&i; *dp=%d\n", *dp); printf("A after inrcP(A): { %d, %d, %d }\n", A[0], A[1], A[2]); incrP(A); printf("A after inrcP(A): { %d, %d, %d }\n", A[0], A[1], A[2]); incrP(dp); printf("i after inrcP(dp): %d\n", i); }