milardovich

STRCHR

Aug 12th, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. /* strchr example */
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. int main ()
  6. {
  7.   char str[] = "This is a sample string";
  8.   char * pch;
  9.   printf ("Looking for the 's' character in \"%s\"...\n",str);
  10.   pch=strchr(str,'s');
  11.   while (pch!=NULL)
  12.   {
  13.     printf ("found at %d\n",pch-str+1);
  14.     pch=strchr(pch+1,'s');
  15.   }
  16.   return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment