char *strstr( const char *string, const char *strCharSet );
Libraries
LIBC.LIB | Single thread static library, retail version |
Return Value
Each of these functions returns a pointer to the first occurrence of strCharSet in string, or NULL if strCharSet does not appear in string. If strCharSet points to a string of zero length, the function returns string.
Parameters
string
Null-terminated string to search
strCharSet
Null-terminated string to search for
Remarks
The strstr function returns a pointer to the first occurrence of strCharSet in string. The search does not include terminating null characters. wcsstr and _mbsstr are wide-character and multibyte-character versions of strstr. The arguments and return value of wcsstr are wide-character strings; those of _mbsstr are multibyte-character strings. These three functions behave identically otherwise.
e.g:
#include "stdafx.h"
#include "string.h"
int main(int argc, char* argv[])
{
char *str = "hello python,hello word.";
char *s = "llo";
char *p;
p = strstr(str,s);
if(p)
{
printf("%s",p);
printf("\r\n");
}
else
{
printf("strstr had not found %s!",s);
}
getchar();
return 0;
}
#include "stdafx.h"
#include "string.h"
int main(int argc, char* argv[])
{
char *str = "hello python,hello word.";
char *s = "c++";
char *p;
p = strstr(str,s);
if(p)
{
printf("%s",p);
printf("\r\n");
}
else
{
printf("strstr had not found %s!",s);
}
getchar();
return 0;
}