Question: search substring in the str(string) and return the index from where it starts. DO NOT use any library functions. int search_substring(std::string& sub, std::string& str); package

search substring in the str(string) and return the index from where it starts. DO NOT use any library functions.

int search_substring(std::string& sub, std::string& str);

package this above function in a separate file and call it from your main program and link it separately at compile time

let us say you wrote your function search_substring() in ss.cpp

g++ -c ss.cpp

above call will create object file

main.cpp is main program

g++ -omain main.cpp ss.o

Example:

str = "This is my computer";

sstr = "my"

int i = search_substring(sstr, str);

i should 8 in this case.

*******************************************************

#include #include

int seach_substring(std::string& sub, std::string& str){

}

int main() { std::string sub = "my"; std::string str = "This is my computer"; int i = seach_substring(sub, str);

std::cout<

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!