#include <iostream>
using namespace std;
void RemoveNumber(char * str)
{
char *read = str;
char *write = str;
while (*read != '\0')
{
if (*read < '0' || *read > '9')
{
*write = *read;
write++;
}
read++;
}
*write = '\0';
}
int main()
{
char str[] = "a88b";
RemoveNumber(str);
cout<<str<<endl;
return 0;
}
a 8 8 b
a b 8 b
a b \0 b
畅游笔试题,复杂度O(n),STL remove算法。