diff options
Diffstat (limited to '1')
| -rw-r--r-- | 1/13.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -1,21 +1,21 @@ #include <stdio.h> -#define MAXWRD 100 +#define MAXIN 100 /* prints a histogram of lengths of words in the input */ int main(int argc, char *argv[]) { int i, j, prev, curr, wordc, charc; - int stats[MAXWRD]; + int stats[MAXIN]; prev = '0'; charc = wordc = 0; - for (i = 0; i < MAXWRD; i++) + for (i = 0; i < MAXIN; i++) stats[i] = 0; while ((curr = getchar()) != EOF) { - if (wordc >= MAXWRD) { - printf("Max word count %d exceeded\n", MAXWRD); + if (wordc >= MAXIN) { + printf("Max word count %d exceeded\n", MAXIN); return 1; } @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) { prev = curr; } - for (i = 0;(charc = stats[i]) > 0 && i < MAXWRD; i++) { + for (i = 0;(charc = stats[i]) > 0 && i < MAXIN; i++) { printf("%3d: ", i + 1); for (j = 0; j < charc; j++) putchar('x'); |
