Question: In C, implement function const char *qstr_strstr(const char *str1, const char *str2) that searches for the substring str2 from the string str1 . The function

In C, implement function const char *qstr_strstr(const char *str1, const char *str2) that searches for the substring str2 from the string str1. The function should return a pointer to the first occurance of str2 in str1. If the substring isnt found, the function should return NULL (note that NULL is defined in stddef.h header). Remember that the function should only search until the first ? character. (Do not use string.g library)

For example, if the function gets the following strings as parameters:

char *str1 = "Auto ajoi katua pitkin?"; char *str2 = "katu?";

it should return a pointer that points to the first character of the word katua where the first occurance of the substring katu begins.

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 Databases Questions!