Question: Needs to be written in C Language Phase 1 In Phase 1, write a function words ) that takes a character string str as input,

Needs to be written in C Language
Phase 1 In Phase 1, write a function words ) that takes a character string str as input, and returnsa dynamically allocated, fixed-lengthed, NULL-terminated array of pointers to dynamically allocated copies of words in the given string str. That's a mouthful, but the underlying idea i:s really simple:) The function can be declared as: char **words char *str The words in str are separated by whitespace, i.e. blanks, tabs, and newlines. The words () function detects all words in str, copies each word into some new space allocated by malloc ), and returns an array with pointers to these new spaces. The array can be of some fixed length, say 64, but will have as many pointers as the number of words in str, followed by a NULL pointer. As an example, if str "Rajiv Bagai rocks ! ! ", then it has 3 words, namely "Rajiv", "Bagai", and "rocks!!". After making copies of these 3 words, the words function will return an array of 64 pointers. Only the first 4 elements in the array will have useful pointer values, namely to the newly created copies of these 3 words, and NULL As a final detail, if str has more than 63 words, just ignore the extra ones. Note: There are many other ways of accomplishing the above breakup of a string into words, like using a static, global array of pointers, etc. As long as you make Phase 2 work, feel free to employ any design for Phase
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
