C Language: strstr function
(Search String for Substring)
In the C Programming Language, the strstr function searches within the string pointed to by s1 for the string pointed to by s2. It returns a pointer to the first occurrence in s1 of s2.
Syntax
The syntax for the strstr function in the C Language is:
char *strstr(const char *s1, const char *s2);
Parameters or Arguments
- s1
- A string to search within.
- s2
- The substring that you want to find.
Returns
The strstr function returns a pointer to the first occurrence s2 within the string pointed to by s1. If s2 isn't found, it returns a null pointer.
Required Header
In the C Language, the required header for the strstr function is:
#include <string.h>
Applies To
In the C Language, the strstr function can be used in the following versions:
- ANSI/ISO 9899-1990
See Also
Other C functions that are noteworthy when dealing with the strstr function:
Advertisements