![]() |
![]() |
![]() |
C++ Reference: strchr()
strchr()
Declaration
char* strchr(const char* kcpString, int iChar);
Description
This function returns a pointer to the first instance of "iChar" in the null-terminated string "kcpString." If the function fails to find an instance of "iChar," it returns NULL.
Example
#include <cstdio>
#include <cstring>
int main()
{
char caString[] = "XoaX.net";
char* cpFound = strchr(caString, 'n');
printf("Found character: %c\n", *cpFound);
printf("Found at char %i\n", (cpFound - caString));
return 0;
}
Output:
![]() |
![]() |
![]() |
| Home | | | Reference | | | Play Games! | | | Blog | | | Forum | | | Site Map | | | Contact Us |





