blob: 3f122bbd9475a10a319703806176772515c2c57d (
plain) (
tree)
|
|
#include <stdio.h>
void squeeze_char(char s[], char c) {
int i;
int j;
for (i = j = 0; s[i] != '\0'; i++)
if (s[i] != c)
s[j++] = s[i];
s[j] = '\0';
}
void squeeze_str(char s1[], char s2[]) {
int i;
for (i = 0; s2[i] != '\0'; ++i)
squeeze_char(s1, s2[i]);
}
void squeeze_all(char s1[], char s2[]) {
int i;
int j;
int k;
for (k = 0; s2[k] != '\0'; ++k) {
for (i = j = 0; s1[i] != '\0'; ++i)
if (s1[i] != s2[k])
s1[j++] = s1[i];
s1[j] = '\0';
}
}
int main() {
char squeezed[] = "abracadabra";
squeeze_all(squeezed,"abc");
printf("%s\n", squeezed);
}
|