Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <stdlib.h>
- #include <string.h>
- char *squeeze(char *s1, char *s2)
- {
- int size = 0;
- for(int i = 0; s1[i] != '\0'; i++, size++)
- ;
- for(int i = 0; s1[i] != '\0'; i++)
- {
- for(int j = 0; s2[j] != '\0'; j++)
- {
- if (s1[i] == s2[j])
- {
- for(int k = i; k < size; k++)
- s1[k] = s1[k + 1];
- i--;
- size--;
- break;
- }
- }
- }
- return s1;
- }
- int main(void)
- {
- char *str1 = malloc(sizeof(char) * 256);
- char *str2 = malloc(sizeof(char) * 256);
- strcpy(str1, "Mother washed the window");
- strcpy(str2, "Mother washed the window");
- printf("%s\n%s\n", str1, str2);
- str1 = squeeze(str1, str2);
- printf("%s\n", str1);
- free(str1);
- free(str2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement