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

  1. /* array7.c: Stores strings in 2-d char arrays */
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. main()
  7. {
  8.     char array[][5] = {"now","is","the","time"};
  9.     size_t n = sizeof array / sizeof array[0];
  10.     int i;
  11.  
  12.     for (i = 0; i < n; ++i)
  13.         printf("array[%d] == \"%s\","
  14.                "\tsize == %d,"
  15.                "\tlength == %d\n",
  16.                i,array[i],
  17.                sizeof array[i],
  18.                strlen(array[i]));
  19.     return 0;
  20. }
  21.  
  22. /* Output
  23. array[0] == "now",  size == 5,  length == 3
  24. array[1] == "is",   size == 5,  length == 2
  25. array[2] == "the",  size == 5,  length == 3
  26. array[3] == "time", size == 5,  length == 4
  27. */
  28.  
  29.