Question: As we need to separate the string into three parts, we need to use the strtok function twice. The first time the string is separated

As we need to separate the string into three parts, we need to use the strtok function twice. The first time the string is separated into 10 and -Dec-2017 using strtok. Then, the second string is separated into Dec and -2017 using strtok. (As leading delimiters are ignored the second - is found as the delimiter in -Dec-2017.) Finally, we need to remove the - from the string -2017; this can be done by just indexing from the second character to the end of the string. An example of calling this function follows: >> [d, m, y] = separatedate d = 10 m = Dec y = 2017 Note that no input arguments are passed to the separatedate function; instead, the date function returns the current date as a string. Also, note that all three output arguments are strings.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!