/* Deletes each character in string s1 that matches any character in * string s2. This program performs the same function as "squeeze," * but it uses a different technique to do the checking. It took me * way too long to write this fucksticker! */ #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, match; match = 0; k = 1; for (i = 0; str1[i] != '\0';) { for (j = 0; str2[j] != '\0'; j++) { if (str1[i] == str2[j]) { match = 1; break; } } /* on the one hand, it's a kludge. * on the other, it was hard to code, * it's kinda hard to understand, * and i'm rather impressed that i * was able to create the sonofabitch. */ if (match) { str1[i] = str1[k++]; match = 0; } else { str1[++i] = str1[k++]; } } } /* don't let the segfault hit you in the ass on the way out ;) */