📄 0 去除[].cpp
字号:
//对文件做预处理
//1.从mr.txt读入
//2.mr1.txt作为读出
//预处理解决问题:19980101-01-001-001/m 子串会被删除
#include <stdio.h>
void main()
{// char *i;
FILE *fp;FILE *fpw;
fp=fopen("199801.txt","r");//读入文件
fpw=fopen("dic_try1.txt","w");//写入文件
int flag=0;//字符状态标志 1:处理1998类问题,0:不是
if (fp==NULL)
{ printf("cannot open thi file\n");}
if (fpw==NULL)
{ printf("cannot open thi file\n");}
printf("%d \n",'[');
while(!feof(fp))
{
unsigned int c1 =fgetc(fp);//printf("%x\n",c1);
if(c1==-1){continue;}//处理文件结尾符作为字符显示的问题
// if(c1==93){c1 =fgetc(fp);c1 =fgetc(fp);continue;}//处理"]"问题
//
if(c1==91 || c1==93) continue;
if(c1==10){ fputc(c1,fpw);continue;}//处理回车
if(c1==32 && flag==1){flag=0;}//如果是1998后面的空格;
if(c1==32){ //处理空格
// flag=0;//遇到空格变为处理ascii码状态
fputc(c1,fpw);
continue;}
if(c1<161){//不是一个GBK
/*
if (c1>=48 && c1<=57) //是数字
{
flag=1;continue;
}//处理1998-类的问题
*/
if(flag!=1)fputc(c1,fpw);
}
else{ //是一个GBK
fputc(c1,fpw);
unsigned int c2 =fgetc(fp);
// if (c1>=176)//修正说明:(c1>176)改为(c1>=176)
// {
fputc(c2,fpw);
// }
//printf("%x,%x\n",c1,c2);
//long f=ftell(fp);
//
}
}
fclose(fpw);
fclose(fp);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -