C strstr() Function

You are Here:

C strstr() Function

The strstr() function determines the first occurrence of a given string in another string.


C Compiler
#include <stdio.h> #include <string.h> int main() { char str1[] = "wikimass is awesome and is good"; char str2[] = "is"; char *ret; ret = strstr(str1, str2); printf("substring: %s", ret); return 0; }


substring: is awesome and is good


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

Parameter Values

str1RequiredSpecifies the string 1
str2RequiredSpecifies the string 2

Return Value

AddressReturns the pointer location from where the second string starts in the first string.
NULLIf the second string was not found in the first string.


Hi Developers, we almost covered 98% of String functions and Interview Question on C with examples for quick and easy learning.

We are working to cover every Single Concept in C.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author