CJCoding With Joseph
15per day

Count Words with Extra Spaces

Write a program that reads a line of text into a character array and counts how many words it contains.

This time, the input may have extra spaces at the beginning, at the end, or multiple spaces between words. You should count only real words (sequences of non-space characters).

Example inputs: "  Dog", "Dog   Cat", "  One  Two   Three  ".

Output the word count as a single integer.

Expected Output:

2
Topics:
Arrays
๐Ÿ“ฅ Auto-Input:
Dog\n
This input is automatically fed to your program's stdin
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.