I've been trying to use a function as a part of a code where the function analyses user input and finds the amount of suffixes used from a given list but the function enters an infinite loop and doesn't work properly - I can't figure out why. Edit: I've implemented your suggestions but it still sends me into a loop where it asks me to provide input and doesn't stop even if I put in '.'
bool read_sentence(char* noun_suffixes[], int noun_suffixes_len,
char* verb_suffixes[], int verb_suffixes_len,
char* adj_suffixes[], int adj_suffixes_len,
int* num_of_nouns, int* num_of_verbs, int* num_of_adjs)
{
char word[MAX_LEN]; char new_word[MAX_LEN];
word[0] = '\0'; new_word[0] = '\0';
int k = 0; unsigned int i = 0;
while ((k == 0))
{
scanf("%s", word);
printf("word is %s", word);
for (i = 0; i < strlen(word) - 1; i++) {
new_word[i] = toLower(word[i]);
if (word[i] == '.')
{
k = 1;
}
}
printf("%s", new_word);
if (is_suffix_in_dict(word, noun_suffixes, noun_suffixes_len) == TRUE)
*(num_of_nouns) += 1;
if (is_suffix_in_dict(word, verb_suffixes, verb_suffixes_len) == TRUE)
*(num_of_verbs) += 1;
if (is_suffix_in_dict(word, adj_suffixes, adj_suffixes_len) == TRUE)
*(num_of_adjs) += 1;
word[0] = '\0'; new_word[0] = '\0';
}
return(TRUE);
}