|

楼主 |
发表于 2013-7-11 23:58:45
|
显示全部楼层
- void CtxtclearerDlg::OnBnClickedBtnClear()
- {
- char fname[200];
- strcpy(fname,(LPCTSTR)cs_txtadd);
- FILE * textclear=fopen(fname,"r");
- char (* line)[51];
- char ch;
- int num=0,ct;
- while((ch=getc(textclear))!=EOF)
- {
- if (ch==':')
- {
- num++;
- }
- }
- line=(char (*)[51])malloc(51*sizeof(char)*num);
- rewind(textclear);
- for (int num2=0;num2<num;num2++)
- {
- fgets(line[num2],50,textclear);
- }
- for(int i=0;i<num;i++)
- {
- for (int j=0;j<num;j++)
- {
- if (!strcmp(line[i],line[j]))
- {
- line[j][0]='|';
- }
- }
- }
- fclose(textclear);
- strcpy(fname,"red.txt");
- FILE * newtxt=fopen(fname,"w");
- for(int b=0;b<num;b++)
- {
- if (line[b][0]!='|')
- {
- fputs(line[b],newtxt);
- }
- }
- free(line);
- fclose(newtxt);
- // TODO: 在此添加控件通知处理程序代码
- }
复制代码 |
|