An assignment in the K&R C Programming 2nd edition says that I have to write a program to print a histogram of the lengths of words in its input. I believe I know how to do so, but when running a test program on arrays, which I have only just learned about, all I get is "8", no matter what I input. This is the program so far:
#include <stdio.h>
/* write a program to print a histogram
of the lengths of words in its input */
main()
{
int wl[11];
int cc, c;
while ((c=getchar()) != EOF);
{
if (c != ' ')
++cc;
if (c == ' ' && cc == '1')
{
++wl[0];
c = 0;
}
putchar(wl[0]);
}
}
It may be just because I'm a total beginner in programming, but I honestly cannot see where I went wrong here. Any help would be appreciated.