/* * Program to count alphabet characters in input file and produce output * file listing each letter found and how many times it was found. * * Program uses "tolower" to convert input characters to lower case and * only counts those for which the islower(result) is true. * * Program also prints to stdout the total number of characters in the * input file and how many were counted. * * Names of input and output files are given as command-line arguments. */ #include #include #include #include #include "alphabet.h" int main(int argc, char * argv[]) { if (argc < 3) { printf("usage %s infile outfile\n", argv[0]); return 1; } FILE * infile = fopen(argv[1], "r"); if (infile == NULL) { printf("could not open %s\n", argv[1]); return 1; } char alphabet[SCHAR_MAX+2]; build_alphabet(alphabet); printf("alphabet '%s'\n", alphabet); /* * FIXME your code goes here * * outline: * * define an array of counters (as in "mergecounts" -- notice * that strlen(alphabet) tells you how many you need) * process infile a character at a time, incrementing counters * close infile * write nonzero counters to output file * print counts of alphabetic and all characters */ return 0; }