/* * implementations of functions in alphacounters.h */ #include "alphacounters.h" #include #include #include #include letter_count_t * build_alphacounters(int *sz) { /* first count how many characters meet criterion for inclusion */ int count = 0; for (int c = SCHAR_MIN; c <= SCHAR_MAX; ++c) { if (islower(c)) { ++count; } } *sz = count; /* now allocate space and build array */ letter_count_t * counters = malloc(sizeof(counters[0]) * count); if (counters != NULL) { count = 0; for (int c = SCHAR_MIN; c <= SCHAR_MAX; ++c) { if (islower(c)) { counters[count] = (letter_count_t) { c, 0 }; ++count; } } } return counters; } void print_alphabet(FILE * f, letter_count_t counters[], int num_counters) { fputs("alphabet '", f); for (int i = 0; i < num_counters; ++i) { fputc(counters[i].letter, f); } fputs("'\n", f); } bool update_counter(char ch, int incr, letter_count_t counters[], int num_counters) { /* FIXME your code goes here */ return false; /* FIXME temporary so compiler doesn't complain */ }