Small white, the same code ran out of the Windows platform no problem under the Linux ran short of both characters
And ran out of the code the character in the string is automatically changed this situation ah
CodePudding user response:
The source and target chain overlap, using a different function,CodePudding user response:
Not tried, we had three days of the scalpCodePudding user response:
Didn't see have what problem, strcpy memory also can overlap, not a problemVoid deletestr (STR, char * const char * STRD) {
While (1) {
Char * pos=STRSTR (STR, STRD);
If (NULL==pos) return;
Strcpy (pos, pos + strlen (STRD));
Printf (" % s \ n ", STR);
}
}
Int main (int arg c, const char * argv []) {
Char STR []={" 00111001110011000010000 "};
Printf (" 01234567890123456789012 \ n \ n % s ", STR);
Deletestr (STR, "1");
Printf (" 01234567890123456789012 \ n \ n % s ", STR);
return 0;
}
You have a try, is where the output is not normal
Under normal circumstances, deleteStr function strcpy among each perform a, output string can short one character
01234567890123456789012
00111001110011000010000
0011001110011000010000
001001110011000010000
00001110011000010000
0000110011000010000
000010011000010000
00000011000010000
0000001000010000
000000000010000
00000000000000
01234567890123456789012
00000000000000