Q:

implement two unique implementations of the string search function in C (WITHOUT using any standard library functions)

0

The strstr function returns a pointer to the first occurrence in haystack of any of the entire sequence of characters specified in needle, or a null pointer if the sequence is not present in haystack. Using this information, implement two unique implementations of the string search function in C (WITHOUT using any standard library functions). In both implementations, define he function so it calls the assert macro to make sure that each parameter is not NULL.

The first implementation must use array notation as much as possible, and traverse each given string using an index relative to the beginning of the string.

The second implementation must use pointer notation as much as possible, and traverse each given string using an incremented pointer — not using an index relative to the beginning of the string. It is unacceptable to create this implementation simply by replacing each occurrence of a[i] with *(a+i). Begin your second implementation as follows:

char *myStringSearch(const char *pcHaystack, const char *pcNeedle) {

/* your code here */

}

The first implementation of strstr should be similar to the line of code above, but with arrays instead of pointers and the restrictions described earlier.

All Answers

total answers (0)

Similar questions


need a help?


find thousands of online teachers now