好吧,给个char的,替换单个字符。这样会快一些吧,这个是置换,连长度都不用了
bool ReplaceChar(char *str,const char src, const char dst)
{
/* old -> new */
if (str == NULL) {
return false;
}
while((str = strchr(str, src)) != NULL) {
*str = dst;
str += 1;
}
return true;
}