home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_11_09 / 1109110a < prev    next >
Text File  |  1993-07-13  |  650b  |  31 lines

  1. /* array1.c: Uses an array name as a pointer */
  2.  
  3. /* NOTE: Pointers and ints are 2-bytes in all examples */
  4.  
  5. #include <stdio.h>
  6.  
  7. main()
  8. {
  9.      int a[] = {0,1,2,3,4};
  10.      int *p = a;
  11.  
  12.      printf("sizeof a == %d\n",sizeof a);
  13.      printf("sizeof p == %d\n",sizeof p);
  14.  
  15.      printf("p == %p, &a[0] == %p\n",p,&a[0]);
  16.      printf("*p == %d, a[0] == %d\n",*p,a[0]);
  17.      p = a + 2;
  18.      printf("p == %p, &a[2] == %p\n",p,&a[2]);
  19.      printf("*p == %d, a[2] == %d\n",*p,a[2]);
  20.      return 0;
  21. }
  22.  
  23. /* OUTPUT
  24. sizeof a == 10
  25. sizeof p == 2
  26. p == FFEC, &a[0] == FFEC
  27. *p == 0, a[0] == 0
  28. p == FFF0, &a[2] == FFF0
  29. *p == 2, a[2] == 2
  30. */
  31.