/* The C Programming Language
My answer to exercise 2-4 */
#include <stdio.h>
#include <string.h>
void remdupe(char[], char[]);
int main(int argc, char* argv[])
{
char s[] = "this is a sentence";
char remove[] = "isa";
remdupe(s,remove);
printf("%s", s);
return 0;
}
/* Remove all characters from s1 that
are existant in s2 */
void remdupe(char *s1, char *s2)
{
int i,j,k, m;
i = j = k = m = 0;
for( i = k = 0; i < strlen(s1); ++i ){
for (j = m = 0; j < strlen(s2); ++j){
if (s1[i] == s2[j]){
m = 1;
j = strlen(s2);\
}
}
if (m != 1)
s1[k++] = s1[i];
}
s1[k] = '\0';
}