Define a function, enter two strings, and delete the even strings that appear in the second string from the first string. For example, if you delete the character "auiou" in the second character from the first string "We are students.", the result is "w r stdnts"
Solution: use hash to search.
# Include <stdio. h> void deletestr2fromstr1 (char * str1, char * str2) {If (str1 = NULL | str2 = NULL | * str1 = '\ 0' | * str2 =' \ 0') return; int hash [256]; for (INT I = 0; I <256; ++ I) hash [I] = 0; char * P = str2; while (* P! = '\ 0') hash [* P ++] ++; char * strfront = str1; int Len = strlen (str1); int small =-1; for (INT I = 0; I <Len; ++ I) {If (hash [* (strfront + I)] = 0) str1 [++ small] = * (strfront + I);} str1 [++ small] = '\ 0';} int main () {char str1 [] = "We are students"; char str2 [] = "aeiou"; deletestr2fromstr1 (str1, str2); printf ("% s", str1 ); return 0 ;}
Removes the characters that appear in another string from one string.