|
Description
This example uses the
strstr function to see if a string
appears in another string
Code
/**************************************
this example uses the strstr function
to
check if str2 appears in str1
***************************************/
#include <stdio.h>
#include <string.h>
int main(void)
{
char *str1 = "programmershelp.co.uk
c section";
char *str2 = "section";
char *substring;
/*check to see if str2 is in str1*/
substring = strstr(str1,str2);
if (substring != NULL)
printf("%s\n",substring);
return 0;
}
Information
tested using Visual
C++ 6
|