Pointer to the null-terminated string to be searched.
2nd Parameter Type : const char *
Pointer to read-only string
2nd Parameter
Pointer to the null-terminated substring to search for in `haystack`.
Read more about parameters of strstr in parameters section
The strstrfunction in C language Finds the first occurrence of the substring in the string.
The strstr function locates the first occurrence of the null-terminated string needle in the null-terminated string haystack. The terminating null characters are not compared.
The strstrfunction takes 2
parameters:
•
const char * `haystack`: Pointer to the null-terminated string to be searched.
•
const char * `needle`: Pointer to the null-terminated substring to search for in `haystack`.
Searches the string `haystack` for the first occurrence of the substring `needle`. Returns a pointer to the beginning of the found substring in `haystack`, or `NULL` if the substring is not found.
The strstr function return value :
Returns a pointer to the first occurrence of needle in haystack, or NULL if needle is not part of haystack
Output
This example demonstrates basic usage of strstr to find a substring within a string.