[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CStrchr
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CStrchr
(C) strchr
The function strchr returns a pointer to the first location of a char is a ?string. If the char is not found, it returns null.Declaration
char * strchr ( const char *, int );
Example
int main() { const char myString[] = "Bilderbikkel"; /* Find the first 'k' */ const char * const myPointer = strchr(myString,'k'); /* Check that it indeed points to a 'k' */ assert(*myPointer == 'k'); /* Check that it indeed points to the first 'k', */ /* by checking that the previous position is 'i' */ assert(* (myPointer-1) == 'i'); }
- include <string.h>
- include <assert.h>
'strchr' links
Code links
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
