C++ strstr() Function


This function returns the pointer to the first occurrence of the string in a given string.

Syntax:

char *strstr(const char *str1, const char *str2);

Example:

#include <iostream>   
#include <cstring>
using namespace std;

int main () {
    char str1[30] = "Welcome to Onlinetpoint";
    char str2[30] = "Onlinetpoint";
    char *str3;
    str3=strstr( str1, str2);
	cout << "String of String: "<< str3 ;
    return 0;
}



OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.