Question
the language is C *Code starts here NOTE: You should NOT use array notation inside your functions. Use only * pointer notation for any code
the language is C
*Code starts here
NOTE: You should NOT use array notation inside your functions. Use only * pointer notation for any code that you write. * */
#include #include // NO additional imports allowed. You *can* make helper functions if you wish.
#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
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