/** * reader - read a bunch of strings and store them in an array. */ #include #include #include int main (int argc, char *argv[]) { int width = 32; if (argc > 1) width = 1 + atoi (argv[1]); int lines = 16; int i, num_strings; char strings[lines][width]; // Read in the strings i = 0; while (fgets (strings[i++], width, stdin) != NULL) ; num_strings = i-1; // Print out the strings printf ("%d strings read.\n", num_strings); for (i = 0; i < num_strings; i++) printf ("%2d: %s", i, strings[i]); // And we're done return 0; } // main