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 >
Wrap
Text File
|
1993-07-13
|
668b
|
29 lines
/* array7.c: Stores strings in 2-d char arrays */
#include <stdio.h>
#include <string.h>
main()
{
char array[][5] = {"now","is","the","time"};
size_t n = sizeof array / sizeof array[0];
int i;
for (i = 0; i < n; ++i)
printf("array[%d] == \"%s\","
"\tsize == %d,"
"\tlength == %d\n",
i,array[i],
sizeof array[i],
strlen(array[i]));
return 0;
}
/* Output
array[0] == "now", size == 5, length == 3
array[1] == "is", size == 5, length == 2
array[2] == "the", size == 5, length == 3
array[3] == "time", size == 5, length == 4
*/