Advertisement
amermo

izbaci substring - bez string.h

Feb 15th, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5.  
  6.  
  7. void izbaci(char* string, char* substring)
  8. {
  9.     while(*string != '\0')
  10.     {
  11.         char* sub = substring;
  12.         char* str = string;
  13.         while(*sub != '\0' && *str == *sub)
  14.         {
  15.             sub++;
  16.             str++;
  17.         }
  18.         if(isalpha(*sub)==0)
  19.         {
  20.             while(*str != '\0')
  21.             {
  22.                 *string++=*str++;
  23.             }
  24.             *string = '\0';
  25.         }
  26.         string++;
  27.     }
  28. }
  29.  
  30. int main()
  31. {
  32.     char s[]="izbaci ovuh test";
  33.     izbaci(s, "ovu");
  34.     puts(s);
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement