use of strstr in c++

C++
// CPP program to illustrate strstr() 
#include <string.h> 
#include <stdio.h> 
  
int main() 
{ 
    // Take any two strings 
    char s1[] = "GeeksforGeeks"; 
    char s2[] = "for"; 
    char* p; 
  
    // Find first occurrence of s2 in s1 
    p = strstr(s1, s2); 
  
    // Prints the result 
    if (p) { 
        printf("String found\n"); 
        printf("First occurrence of string '%s' in '%s' is '%s'", s2, s1, p); 
    } else
        printf("String not found\n"); 
  
    return 0; 
} 
// CPP program to illustrate strstr() 
#include <string.h> 
#include <stdio.h> 
  
int main() 
{ 
    // Take any two strings 
    char s1[] = "Fun with STL"; 
    char s2[] = "STL"; 
    char* p; 
  
    // Find first occurrence of s2 in s1 
    p = strstr(s1, s2); 
  
    // Prints the result 
    if (p) { 
        strcpy(p, "Strings"); 
        printf("%s", s1); 
    } else
        printf("String not found\n"); 
  
    return 0; 
} 
/* strstr example */
#include <stdio.h>
#include <string.h>

int main ()
{
  char str[] ="This is a simple string";
  char * pch;
  pch = strstr (str,"simple");
  strncpy (pch,"sample",6);
  puts (str);
  return 0;
}#include <iostream>
#include <string.h>

using namespace std;
int main() {
   char str1[] = "Apples are red";
   char str2[] = "are";
   char *ptr;
   ptr = strstr(str1, str2);

   if(ptr)
   cout<<"Occurance of \""<< str2 <<"\" in \""<< str1 <<"\" is at position "<<ptr - str1 + 1;

   else
   cout<<"There is no occurance of \""<< str2 <<"\" in "<<str1;
   return 0;
}
Source

Also in C++: