char* func(char *str, char ch)
{
size_t size = strlen(str), count = 0;
for (size_t i = 0; i < size; i++)
{
if (str[i] == ch)
{
++count;
}
}
if (count)
{
char *pc = new char[size + 1 - count];
int temp = 0, num = 0;
while (str[num] != '\0')
{
if (str[num] != ch)
{
*(pc + temp) = str[num];
++temp;
}
++num;
}
memset(str, 0, size);
strcpy(str, pc);
delete[] pc;
}
return str;
}
在制定字符串内删除指定字符。
最新推荐文章于 2023-07-27 14:06:44 发布