strstr

Scans a string for the first occurrence of a given substring

Local Servers:nonblocking
Remote Servers:N/A
Classification:ANSI
Service:String Manipulation

Syntax

  #include <string.h>  
   
  char *strstr  (  
     const char   *str,   
     const char   *substr);
  

Parameters

str
(IN) Points to the string to be scanned.
substr
(IN) Points to the substring for which to search.

Return Values

The strstr function returns a pointer to the located string, or NULL if the string is not found.

Remarks

The strstr function locates the first occurrence in the string pointed to by str of the sequence of characters (excluding the terminating NULL character) in the string pointed to by substr.

See Also

strcspn, strpbrk

Example

  #include <string.h>  
  #include <strio.h>  
   
  main ()  
  {  
     printf ("%s\n", strstr ("This is an example", "is") );  
  }
  

produces the following:

  is is an example