Advertisement
CamolaZ

ponteiros e strchr o que faz

Feb 16th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. /* strchr example */
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <cstdio>
  5. #include <cstring>
  6. using namespace std;
  7.  
  8. int main ()
  9. {
  10.     char s[100],c;
  11.    
  12.     printf("Introd. uma string: "); gets(s);
  13.     printf("Introd. um char   : "); scanf(" %c", %c);
  14.    
  15.     puts(stchr(s,c));
  16.   /*char str[] = "This is a sample string";
  17.   char * pch;
  18.   printf ("Looking for the 's' character in \"%s\"...\n",str);
  19.   pch=strchr(str,'s');
  20.   while (pch!=NULL)
  21.   {
  22.     printf ("found at %d\n",pch-str+1);
  23.     pch=strchr(pch+1,'s');
  24.   }*/
  25.   return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement