Angel David Yaguana Hernandez
/
CPP_strchr
strchr, descripcion y ejemplo
main.cpp
- Committer:
- sherckuith
- Date:
- 2012-04-03
- Revision:
- 0:8b9477b27450
File content as of revision 0:8b9477b27450:
#include "mbed.h" /* strchr example */ #include <stdio.h> #include <string.h> int main () { char str[] = "This is a sample string"; char * pch; printf ("Looking for the 's' character in \"%s\"...\n",str); pch=strchr(str,'s'); while (pch!=NULL) { printf ("found at %d\n",pch-str+1); pch=strchr(pch+1,'s'); } return 0; } /* Output: Looking for the 's' character in "This is a sample string"... found at 4 found at 7 found at 11 found at 18 */