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

  1. /* array5.c: Arrays as parameters */
  2. #include <stdio.h>
  3.  
  4. void f(int b[], size_t n)
  5. {
  6.     int i;
  7.  
  8.     puts("\n*** Entering function f() ***");
  9.     printf("b == %p\n",b);
  10.     printf("sizeof(b) == %d\n",sizeof(b));
  11.      for (i = 0; i < n; ++i)
  12.         printf("%d ",b[i]);
  13.     b[2] = 99;
  14.     puts("\n*** Leaving function f() ***\n");
  15. }
  16.  
  17. main()
  18. {
  19.     int i;
  20.     int a[] = {0,1,2,3,4};
  21.      size_t n = sizeof a / sizeof a[0];
  22.  
  23.     printf("a == %p\n",a);
  24.     printf("sizeof(a) == %d\n",sizeof(a));
  25.     f(a,n);
  26.      for (i = 0; i < n; ++i)
  27.         printf("%d ",a[i]);
  28.     return 0;
  29. }
  30.  
  31. /* Output
  32. a == FFEC
  33. sizeof(a) == 10
  34.  
  35. *** Entering function f() ***
  36. b == FFEC
  37. sizeof(b) == 2
  38. 0 1 2 3 4
  39. *** Leaving function f() ***
  40.  
  41. 0 1 99 3 4
  42. */
  43.  
  44.