int c = 10;
int c2 = 20;
/* define a pointer and points to an constant integer.
pc can point to another integer but you cannot change the
content of it */
const int *pc = &c;
/* pc++; */ /* cause error */
printf("value of pc is %d\n",pc);
pc = &c2;
printf("value of pc is %d\n",pc);
/* define a constant pointer and points to an integer.
py only can point to y and its memory address cannot be changed
you can change its content */
int y = 10;
int y2 = 20;
int const *py = &y;
*py++;/* it is ok */
printf("value of y is %d\n",y);
/* py = &y2; */ /* cause error */
No comments:
Post a Comment