#include<stdio.h> #include<stdlib.h> void delnote(FILE *fp1,FILE *fp2) {int i=0; char c; while(!feof(fp1)) {c=fgetc(fp1); if(c=='\n') fprintf(fp2,"\n"); else switch(i) { case 0:if(c=='/') i=1; else fputc(c,fp2); break; case 1:if(c=='*') i=2; else {fputc('/',fp2); fputc(c,fp2); i=0; } break; case 2: if(c=='*') i=3; break; case 3: if(c=='/') i=0; else i=2; break; } } } main() {FILE *fp1,*fp2; if((fp1=fopen("examp.txt","r"))==NULL) {printf("can't open file examp!\n"); exit(0); } if((fp2=fopen("exampout.txt","w"))==NULL) {printf("can't open file exampout!\n"); exit(0); } delnote(fp1,fp2); fclose(fp1); fclose(fp2); }
把工程下载下来。解压运行就知道了。