Due: Monday, May 21, 5:00pm.
Write two functions that work on null-terminated strings. Contracts and prototypes for them are given below. Test each function carefully using a testing program that you write. Use a tester that runs unattended. It should not require any input from the user. Ideally, it should check its own results. For example, use mystrdup to duplicate a string, and then use library function strcmp to see whether the duplicate has the same characters in it as the original.
//////////////////////////////////////////////////////////////// // mystrdup(s) returns a pointer to a copy of null-terminated // // string s. The copy is allocated using new. // //////////////////////////////////////////////////////////////// char* mystrdup(char *s);
////////////////////////////////////////////////////////////////// // mystrchr(s,c) searches for the first occurrence of character // // c in null-terminated string s. It returns a pointer to // // that first occurrence. If character c does not occur in // // s, then strchr returns NULL. // ////////////////////////////////////////////////////////////////// char* mystrchr(char *s, char c);