Advertisement
sellmmaahh

OR-2007-podstring-pok1

Aug 11th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1.  
  2. #include<stdio.h>
  3.  
  4.  
  5. int sadrzi(char *string, char *podstring)
  6. {
  7.     int duzina=0;
  8.     char *s1=string;
  9.     char *s2=podstring;
  10.     while (*s2!='\0')
  11.     {
  12.         duzina++;
  13.         s2++;
  14.     }
  15.     int br_ima=0;
  16.  
  17.     while (*s1!='\0')
  18.  
  19.     {
  20.         while (*s1==*podstring)
  21.         {
  22.                           s1++;
  23.                        podstring++;
  24.  
  25.             if (*podstring=='\0') br_ima++;
  26.  
  27.         }
  28.         s1++;
  29.         podstring-=duzina;
  30.  
  31.     }
  32.     return br_ima;
  33. }
  34. int main ()
  35. {
  36.     char s1[]="babaroga";
  37.     char s2[]="ba";
  38.     printf("%d",sadrzi(s1,s2));
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement