Listing 7 Implements strings as rows in a 2-d array of char
/* 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 */ /* End of File */