/*******************************************************************
删除字符串中的数字并压缩字符串,
如字符串"abc123de4fg56"处理后变为"abcdefg"。注意空间和效率
********************************************************************/
#include <cstdlib>
#include <iostream>
#include<cstring>
using namespace std;
void hanStr(char *str)
{
int len = strlen(str);
int index = 0;
for(int i=0; i<len; i++)
{
if(!isdigit(str[i]))
str[index++] = str[i];
}
str[index] = '\0';
cout << str << endl;
}
int main(int argc, char *argv[])
{
char a[]="abcd1234efg1234";
hanStr(a);
}
去除字符串中的数字
最新推荐文章于 2023-04-23 21:15:05 发布