This program is mainly to delete characters in string A that contain characters in string B, the Code is as follows:
/*
* Delete a specific character from a string
*/
# Include <stdio. h>
# Include <stdlib. h>
# Include <string. h>
// Delete the characters in the dest that contain the word
Void deleteWord (char * dest, char * word)
{
Int len1 = strlen (dest );
Int len2 = strlen (word );
Int data [256] = {0 };
For (int I = 0; I <len2; I ++)
Data [(unsigned char) word [I] ++;
For (int j = 0; j <len1; j ++)
{
If (data [(unsigned char) dest [j]> 0)
{
Int I = j;
For (; I <len1-1; I ++)
{
Dest [I] = dest [I + 1];
}
Dest [I] = '\ 0 ';
J --;
}
}
}
Int main (int argc, char ** argv)
{
Char a [] = "hello world ";
Char B [] = "ewd ";
Int len1 = strlen ();
Int len2 = strlen (B );
Printf ("input string A: % s \ n", );
Printf ("input string B: % s \ n", B );
DeleteWord (a, B );
Printf ("after delete: % s \ n", );
Return 0;
}
From the column qunqin