Counting words in a string?

后端 未结 4 526
被撕碎了的回忆
被撕碎了的回忆 2021-01-23 07:32

Hello for this program I am supposed to count the number of words in a string. So far, I have found out how to find the number of characters in a string but am unable to figure

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-23 07:45

    When you're in the if part, it means you're inside a word. So you can flag this inword and look whether you change from out of word (which would be your else part) to inword and back.

提交回复
热议问题