Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Advanced cstring function (write this function after lab and turn it in at the next lab for 10 bonus point on the first exam) One
Advanced cstring function (write this function after lab and turn it in at the next lab for 10 bonus point on the first exam) One last function for you to implement. Again, I will provide an overview of the algorithm, but I will not provide you with an implementation from me. You will need to write and test this function to get full credit strtok(): strtoko provides you with a different substring found in the original cstring parsed by a delimit character. Each time you call strtok() the next substring is returned. We will write a different version of strtok(). Our version will return an array of cstrings that is terminated with a value of NULL. Each string found prior to the NULL value will point back into the original cstring. The returned array needs to be dynamically allocated. We will follow this algorithm for dynamically resizing the array of cstrings. Our array will start out with 2 spots and will double in size anytime we need more memory. (If we determine that there are 5 substrings, your return array will need 8 spots.) The algorithm for strtok() is fairly simple. We will look at the cstring, that was passed, a character at a time. For each occurrence of the delimit character we will replace it with a '\0' and set a new pointer to the next spot in the cstring. It will continue to do this until the 'VO' is reached in the original cstring. You will need to write and test your solution to get full credit. Here is your prototype. char ** stuStrTok( char *, char )
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started