![]() |
![]() |
![]() |
C++ Reference: strcspn()
strcspn()
Declaration
size_t strcspn(const char* kcpString, const char* kcpChars);
Description
This function returns the index of the first occurrence of one of the chars in the null- terminated set "kcpChars" inside the null-terminated string "kcpString." If no occurrence is found, the function returns NULL.
Example
#include <cstdio>
#include <cstring>
int main()
{
char caString[] = "XoaX.net";
char caChars[] = "aei";
// Find the first of "aei" inside of "XoaX.net"
int iFound = strcspn(caString, caChars);
printf("First of %s found at %i\n", caChars, iFound);
return 0;
}
Output:
![]() |
![]() |
![]() |
| Home | | | Reference | | | Play Games! | | | Blog | | | Forum | | | Site Map | | | Contact Us |





