Hi to all, I've been trying to write one small program, and I got stuck. I mean, it is finished, it compiles, but does not work as it is supposed to. The task is to keep accepting input from user (words, one by one) until the program spots a four-letter word. That's when it stops and displays the smallest and longest word entered so far.
What is wrong? Well, the "count" variable does not record the new value when entering the while loop again at all. It keeps being incremented by next entered word... What's more, the length of smallest/largest word is not counted at all.
I will appreciate your fresh look at my code...
#define LEN 20
int i = 0;
printf("Enter a word: ");
while( (ch = getchar()) != '\n')
if(i < LEN)
word[i++] = ch;
word[i] = '\0';
count = strlen(word);
count_smallest = strlen(smallest_word);
count_largest = strlen(largest_word);
if(count <= count_smallest)
while(count != 4);
printf("Smallest word is %d letters long and it is: ",
printf("Largest word is %d letters long and it is: ",