From f8d9ff23eb8d3e3286ff5cf4d5f9493532991bb7 Mon Sep 17 00:00:00 2001 From: zlg Date: Thu, 16 Jun 2016 10:15:33 -0700 Subject: The massive astyle sweep! Code style should be consistent now. All future commits will be run through astyle or they will be amended. --- ch1/1-13_word-length-histogram.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'ch1/1-13_word-length-histogram.c') diff --git a/ch1/1-13_word-length-histogram.c b/ch1/1-13_word-length-histogram.c index b557417..a2ee173 100644 --- a/ch1/1-13_word-length-histogram.c +++ b/ch1/1-13_word-length-histogram.c @@ -33,19 +33,17 @@ int main(void) { * lengths = an array that keeps track of how often words up to x chars long * occur. */ - int state, ltrs, wrds, lines, wlen, i, j; int lengths[MAXWLENGTH]; for (i = 0; i <= MAXWLENGTH; ++i) { lengths[i] = 0; } - ltrs = wrds = wlen = 0; lines = 1; state = OUT; - // Capture input until it ends + /* Capture input until it ends */ while ((i = getchar()) != EOF) { - // If it's whitespace, we've exited a word + /* If it's whitespace, we've exited a word */ if (i == '\n' || i == ' ' || i == '\t') { if (state == IN) { ++wrds; // ...and should increase the count. @@ -54,7 +52,7 @@ int main(void) { if (wlen <= MAXWLENGTH) { ++lengths[wlen]; } - // Reset our word length now. + /* Reset our word length now. */ wlen = 0; } /* If it's a new line, we're still out of a word but need to increment the @@ -70,13 +68,12 @@ int main(void) { /* Everything that's input counts as a letter. */ ++ltrs; } - printf("\nWORD LENGTH FREQUENCY\n "); for (i = 5; i < 80; i += 5) { printf(" %2d", i); } - - printf("\n"); // End the chart heading. + /* End the chart heading. */ + printf("\n"); j = MINWLENGTH; while (j <= MAXWLENGTH) { i = lengths[j]; @@ -84,7 +81,7 @@ int main(void) { printf("%2d | ", j); while (i > 0) { printf("#"); - i = i-1; + i = i - 1; } printf("\n"); } -- cgit v1.2.3-54-g00ecf