aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzlg <zlg@zlg.space>2012-11-29 12:02:35 -0600
committerzlg <zlg@zlg.space>2012-11-29 12:02:35 -0600
commit5474f7b679879edb05fb03452886dedff8e27f36 (patch)
tree0117886f953f6c0c8b95beffe2a8ece06933939b
parentSolve Exercise 1-21: entab (diff)
downloadknr-5474f7b679879edb05fb03452886dedff8e27f36.tar.gz
knr-5474f7b679879edb05fb03452886dedff8e27f36.tar.bz2
knr-5474f7b679879edb05fb03452886dedff8e27f36.tar.xz
knr-5474f7b679879edb05fb03452886dedff8e27f36.zip
Correct 1-13's chart heading
Thanks to ##c's rizlah
-rw-r--r--1-13_word-length-histogram.c9
-rw-r--r--1-21_entab.c1
2 files changed, 8 insertions, 2 deletions
diff --git a/1-13_word-length-histogram.c b/1-13_word-length-histogram.c
index 1b4cdc0..1e21378 100644
--- a/1-13_word-length-histogram.c
+++ b/1-13_word-length-histogram.c
@@ -52,8 +52,13 @@ int main(void) {
/* Everything that's input counts as a letter. */
++ltrs;
}
- // This is ugly and I wish I knew a better way to do it.
- printf("\nWORD LENGTH FREQUENCY\n\n 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75\n");
+
+ printf("\nWORD LENGTH FREQUENCY\n ");
+ for (i = 5; i < 80; i += 5) {
+ printf(" %2d", i);
+ }
+
+ printf("\n"); // End the chart heading.
int iter;
iter = MINWLENGTH;
while (iter <= MAXWLENGTH) {
diff --git a/1-21_entab.c b/1-21_entab.c
index 595f583..0f25706 100644
--- a/1-21_entab.c
+++ b/1-21_entab.c
@@ -42,4 +42,5 @@ int main(void) {
putchar(c);
}
}
+ return 0;
}