CJCoding With Joseph
15free / daySign inCreate account

Split a Line into a Heap Token Array

Split one line of text into words and store them in a char ** where every element is its own malloc copy of a word.

Read one line from stdin with fgets (the line is at most 255 characters). Words are separated by one or more spaces, and the line may start with spaces. Collect all the words into your array before printing anything.

Print "count: " followed by the number of words. Then print each word on its own line, wrapped in square brackets.

Sample input:
the quick brown fox

Free the memory you allocate before the program ends — this question checks for memory leaks.

Expected Output:

count: 4
[the]
[quick]
[brown]
[fox]

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Pointers
📥 Auto-Input:
the quick brown fox\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 (p, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.