home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C by Discovery (4th Edition)
/
C_By_Discovery_4th_Edition.tar
/
C_By_Discovery_4th_Edition
/
_DISK_
/
ch5
/
strtst.c
< prev
next >
Wrap
C/C++ Source or Header
|
2005-06-16
|
815b
|
35 lines
/* strtst.c
*
* Synopsis - Calls strstr() twice to find
* substrings in "how now brown cow".
* One should be found, the other is
* nonexistent.
*
* Objective - To provide a test program for
* personal version of strstr().
*/
/* Include Files */
#include <stdio.h>
#include <string.h>
int main( void )
{
char string[] = "How now brown cow";
char *substring;
substring = strstr( string, "own" );
if ( substring == NULL )
printf( "Not found.\n" );
else
printf( "%s\n", substring );
substring = strstr( string, "red" );
if ( substring == NULL )
printf( "Not found.\n" );
else
printf( "%s\n", substring );
return 0;
}