C strstr function

« Previous

Synopsis:

Example

#include <stdio.h>
char *strstr(char *string2, char string*1); 

Description:

The strstr function locates the first occurrence of the string string1 in the string string2 and returns a pointer to the beginning of the first occurrence.

Return Value

The strstr function returns a pointer within string2 that points to a string identical to string1. If no such sub string exists in src a null pointer is returned.

Example

Example

#include <stdio.h>
int main() {
   char s1 [] = "My House is small";
   char s2 [] = "My Car is green";
   printf ("Returned String 1: %s\n", strstr (s1, "House"));
   printf ("Returned String 2: %s\n", strstr (s2, "Car"));
}

Output Will Be :

Output

Returned String 1: House is small
Returned String 2: Car is green


« Previous
Have Any Suggestion? We Are Waiting To Hear from YOU!

Your Query was successfully sent!