diff options
-rw-r--r-- | 1.6.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/1.6.c b/1.6.c index 1d4beef..41004ad 100644 --- 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; } |