What should this function return? And how can you determine in which of the sentences the key word occurs more often?

I wrote the program, but how to do everything in the function?

Write a function that determines whether the user-specified keyword is part of the given character string. On the basis of the developed function, determine which of the sentences contains the specified key set of characters more often.

int main() { char cszSentences[5][100] = {0 }; for (int i=0, i<5.i++) { gets(cszSentences[i]) } char szKeyword[10]; printf("Choose a keyword\n"); gets(szKeyword); int iLen = strlen(szKeyword); int n = 0; for (int i = 0; i < 5; i++) { for(const char *src = cszSentences[i]; (src = strstr(src, szKeyword)) != 0; src += iLen) { n++; } printf("in %d sentence is %d keywords\n", i+1, n); n = 0; } } 
  • If she defines "enters or not" - then she should return bool. - Vladimir Martyanov
  • I think, it should return all the same int. For example, the number of a sentence in which the required word appears more than once if it is there at all, and -1 if there is no such word. - Kirill Malyshev
  • one
    Pointer to the beginning of the word found in the string, or NULL if it has not found (in fact, the standard strstr behaves that way) - avp
  • На основе разработанной функции определить, в каком из предложений больше раз встречается заданное ключевой набор символов. - along with counting n in the same cycle, look for the maximum of them and memorize the corresponding i . After the cycle, the problem is solved. - avp
  • So "key character set" or "keyword"? This is a fundamental difference. A "character set" is a substring. A "word" is usually not just a substring, but, say, a substring framed by spaces. - AnT

0