![]() |
![]() |
![]() |
C++ Reference: strstr()
strstr()
Declaration
char* strstr(const char* kcpString, const char* kcpSubString);
Description
This function returns a pointer to the first occurrence of "kcpSubString" within the string "kcpString." If no occurrence is found, the function returns NULL.
Example
#include <cstdio>
#include <cstring>
int main()
{
char caString[] = "XoaX.net";
char caSubstr[] = "net";
// Find the first "net" inside of "XoaX.net"
char* cpSub = strstr(caString, caSubstr);
int iPos = (cpSub - caString);
printf("First %s found at %i\n", caSubstr, iPos);
return 0;
}
Output:
![]() |
![]() |
![]() |
| Home | | | Reference | | | Play Games! | | | Blog | | | Forum | | | Site Map | | | Contact Us |





