已知一个字串由GBK汉字和ansi编码的数字字母混合组成,编写c语言函数实现从中去掉所有ansi编码的字母和数字(包括大小写),要求在原字串上返回结果。
函数接口为:int filter_ansi(char* gbk_string)
注:汉字的GBK编码范围是0×8140-0xFEFE
#include <iostream>
using namespace std;
Filter_Ansii(const char *p) {
const char * temp = p;
int step = 0;
unsigned int len = strlen(temp);
for(int i = 0; i + step < len; i++) {
while(i + step < len &&
(temp[i] >= '0' && temp[i] <= '9') ||
(temp[i] >= 'a' && temp[i] <= 'z') ||
(temp[i] >= 'A' && temp[i] <= 'Z')) {
step++;
}
if(step != 0) {
temp[i] = temp[i + step];
}
}
temp[i] = '/0';
printf("%s/n", temp);
}