0
program to count no of words in a string
2 Réponses
+ 8
You may refer to my code "Word Reverser". Part of it stores phrases from a string inside an array. By doing that, getting the phrase count is not a problem.
If you mean number of characters though, that would be a much easier task.
+ 1
assume after each word there will be whitespace so use this logic.
run loop through string and increase count by 1 when you encounter whitespace.
no. of words will be more than 1 of this count, since we will miss starting word by this logic.