Split a Line into a Heap Token Array
hardQuestion 480Split 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, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Pointers
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.