0

program to count no of words in a string

21st Feb 2017, 11:47 AM
Chirashish Jeena
2 Respuestas
+ 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.
21st Feb 2017, 1:50 PM
Hatsy Rei
Hatsy Rei - avatar
+ 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.
21st Feb 2017, 1:36 PM
Raj Kumar Chauhan
Raj Kumar Chauhan - avatar