/* Deletes each character in string s1 that matches any character in * string s2. */ #define MAXLEN 50 /* Maximum allowable string length */ #include void squeeze(char str1[], char str2[]); int main() { char c, str1[MAXLEN], str2[MAXLEN]; int i = 0; /* I should write this part as a function... but fuck it */ printf("Please enter a string: "); while ((c = getchar()) != '\n') { if (c == EOF) { printf("\nOh, so you don't wanna play anymore?\n"); exit(0); } else if (i == MAXLEN) { printf("\nToo much input! AIEEEEE!\n"); exit(0); } else str1[i++] = c; } str1[i] = '\0'; i = 0; printf("Please enter another string: "); while ((c = getchar()) != '\n') { if (c == EOF) { printf("\nRunning away, eh?\n"); exit(0); } else if (i == MAXLEN) { printf("\nNo, NO, NOOOOOO!!!!!!"); exit(0); } else str2[i++] = c; } str2[i] = '\0'; squeeze(str1, str2); printf("\nAll the characters in the second string have "); printf("\nbeen removed from the first. The result: "); printf("\n%s\n", str1); printf("\nHave a nice day... FAG!\n"); return 0; } void squeeze(char str1[], char str2[]) { int i, j, k; for (i = 0; str2[i] != '\0'; i++) { for (j = k = 0; str1[j] != '\0'; j++) { if (str1[j] != str2[i]) str1[k++] = str1[j]; } str1[k] = '\0'; } }