C++ Practical
String Processing Snippet-11
Sub-String Handling
Question: Write a substr() that will scan a string for the occurrence of a given sub-string
The prototype of the function would be:
char* substr(char* str1, char* str2);
The function should return a pointer to the element in str1 where str2 begins.
If str2 does not occur in string1 then substr() should return a NULL
e.g. if str1 = "Ena Meena Deeka" and str2 = "Meena"
then substr() should return address of 'M' in str1
write main() that uses the function substr()
Answer:








