Question: *Code starts here NOTE: You should NOT use array notation inside your functions. Use only * pointer notation for any code that you write. *
*Code starts here
NOTE: You should NOT use array notation inside your functions. Use only * pointer notation for any code that you write. * */
#include
#define MAX_STRING_LEN 1024
char *find_last_substring(char *str, char *a) { /** * Given a string `str` and another string `a`, return a pointer to the start * of the *LAST* occurrence of `a` in `str`. (Unlike ex2, where you had to * find the FIRST occurrence). * * For instance, if we had: (here) * V * char str[MAX_STRING_LEN] = "Hello everyone, Hello world!" * char *res = find_last_substring(str, "Hello"); * * then, we would except `res` to be a pointer to the character marked above. * In particular, since the second "Hello" is at index 16, we should get * the following: * * res - str == 16; (This is pointer arithmetic) * * If `a` is not a valid substring of `str`. return NULL. */
return NULL; // Replace with correct return }
I did not include a main function but you are welcome to for testing
Please do NOT include any other c libraries (I've asked this question on chegg and libraries are being used when they are not allowed to be included.) only use the two already included
Also please make sure to USE pointers and NOT arrays directly
Thanks for the help :)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
