CJCoding With Joseph
15free / daySign inCreate account

Count Words in Char Array

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

Assume the input contains words separated by a single space, with no leading or trailing spaces. Example inputs: "Dog", "Dog Cat", "One Two Three".

Output the word count as a single integer.

Expected Output:

1

= newline. No newline after the last line.

Hints4 available
Topics:
Arrays
📥 Auto-Input:
Dog\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.