This section illustrates you how to get the substring using library function. You can see in the given example, we have used the library function strstr() provided by the header file <string.h>. The function is declared as:
char *strstr(const char *str1, const char *str2);
In the given code, we have consider will as str2 and the whole string as str1. The function strstr() finds the occurrence of str2 in the str1 and returns the pointer to occurrence of str2 in str1. If no match found, then a null pointer is returned.
Here is the code:
Output will be displayed as:
Liked it! Share this Tutorial