1

1 Example

0
  int *ptr;  /* Note: the use of * here is not for dereferencing, 
               it is for data type int */
  int x;

  ptr = &x;   /* ptr now points to x (or ptr is equal to address of x) */
  *ptr = 0;   /* set value ate ptr to 0 or set x to zero */

  printf(" x = %d\n", x);   /* prints x =  0 */
  printf(" *ptr = %d\n", *ptr);  /* prints *ptr =  0 */


  *ptr += 5;        /* increment the value at ptr by 5 */
  printf(" x  = %d\n", x);  /* prints x = 5 */
  printf(" *ptr = %d\n", *ptr); /* prints *ptr =  5 */


  (*ptr)++;         /* increment the value at ptr by 1 */
  printf(" x  = %d\n", x);  /* prints x = 6 */
  printf(" *ptr = %d\n", *ptr);  /* prints *ptr =  6 */
by on

Other Code Examples