strstr


strstr

Searches a string for a replica of another string

 #include <string.h> char *strstr ( const char *s1 , const char *s2  ); 

The strstr( ) function searches the string s1 for the first occurrence of the string s2 (not counting s2's terminating null character). The return value is a pointer to the first character in the first occurrence in s1 of the sequence contained in s2, or a null pointer if there is no such occurrence. If s2 points to an empty string, then strstr( ) returns the value of its first argument, s1.

Example

 FILE *fpTx, *fpRx, *fpLog; char rxbuffer[1024], *found; /* ... */ fgets( rxbuffer, 1024, fpRx ); found = strstr( rxbuffer, "assword:" ); if ( found != NULL ) {   fputs( "Got password prompt. Sending password", fpLog );   fputs( "topsecret", fpTx ); } 

See Also

strchr( ), strpbrk( ), wcsstr( )



C(c) In a Nutshell
C in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596006977
EAN: 2147483647
Year: 2006
Pages: 473

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net