英語の日記は、ある程度の単語数が必要です。s の単語の数を数える count_words(s) を書きましょう。単語はスペースで区切られていて、スペースが続くこともあり、最初や最後にスペースがあることもあります。空の文字列なら 0 です。
count_words("went to the zoo")→4count_words("")→0int count_words(const char *s)int count_words(const char *s) {
int words = 0;
for (int i = 0; s[i] != '\0'; i++) {
// ここにコードを書く:スペースではなく、しかも先頭かスペースの直後なら、新しい単語
}
return words;
}
実行すると例で試せます。よさそうなら提出しましょう。