Ceriousmall said:
well I've modified that code since then and the result is as
follows...........
while (at_start != EOF) {
c = getchar();
at_end = c == EOF;
if (c >= '0' && c <= '9'){
nchar = 0;
not_a_word = TRUE;
}
else if (c == ' ' || c == '\n' || c == '\t' || c == EOF) {
if (nchar > 0 && nchar < LIMIT)
++wordlength[nchar];
else if (nchar >= LIMIT)
++wordlength[LIMIT];
nchar = 0;
not_a_word = FALSE;
}
else if (not_a_word == FALSE)
++nchar;
if (at_end)
at_start = EOF;
I am assuming this is the end of the loop.
There's no point in having both at_end and at_start. The purpose of
one seems to be to set the other and noting else.
Can you summarise what you consider to be a word? You make a special case of
digits use an extra variable to exclude some cases that I would have
accepted as words. For example, "2-dimensional" seems to be at least as
much a word as "+-+-+". You will count the second but not the first.
Why do you write "if (not_a_word == FALSE)" but then "if (at_end)"? I'd
stick to one, though I'd strongly recommend not testing Booleans
against constants like TRUE and FALSE.