blob: e195a09f326faa211844be0ab30b8c8c15a5d572 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#include <stdio.h>
/* function to delete each character in str1 that matches with str2 */
char* squeeze(char str[], const char cs[]);
int
main(void)
{
char str[] = "ok chud you win this time";
char del[] = "oi";
printf("%s\n", squeeze(str, del));
return 0;
}
char*
squeeze(char str[], const char cs[])
{
int i, j, k;
for (i = j = 0; str[i] != '\0'; i++) {
for (k = 0; cs[k] != '\0'; k++)
if (str[i] == cs[k])
break;
if (cs[k] == '\0')
str[j++] = str[i];
}
str[j] = '\0';
return str;
}
|