kandr

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 58908e6c604814e325d749228ad834e9fdc20a7f
parent 6740296c1955baf26c77b0037de72a19862dfe8a
Author: aabacchus <ben@bvnf.space>
Date:   Wed, 19 May 2021 02:05:53 +0100

1-13: add usage

Diffstat:
M1.6.c | 13+++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/1.6.c b/1.6.c @@ -1,7 +1,8 @@ #include <stdio.h> + #define OUTWORD 0 #define INWORD 1 -#define MAXWORDLEN 20 +#define MAXWORDLEN 30 int longest(const int *list) { int max = 0; @@ -12,7 +13,14 @@ int longest(const int *list) { return max; } -int main () { +void usage() { + printf("print a histogram of the lengths of words in stdin (K&R ex 1-13)\n"); + printf(" vertical axis is frequency\n"); + printf(" horizontal axis is word length\n"); +} + +int main (int argc, char *argv[]) { + if (argc > 1) { usage(); return 0;} int c, i, j, wordlen; int ndigit[MAXWORDLEN] = {0}; wordlen = 0; @@ -48,4 +56,5 @@ int main () { for (j = 0; j < MAXWORDLEN; ++j) printf("%3d", j); printf("\n"); + return 0; }