#include#include int main(void) { char ch; FILE * fptr, *copyptr; if((fptr = fopen("D:\sun.txt","r"))==NULL) { printf("Can't open the source file.n"); } else if((copyptr = fopen("D:\sun3.txt","w"))== NULL) { printf("Can't open the destination file.n"); } while((ch = fgetc(fptr))!= EOF)//当字符不为空 { if( ch =='/')//当为/时 { if((ch=fgetc(fptr))=='/')//此时光标有移动了,这个时候再读,又为/时 { while((ch=fgetc(fptr))!=EOF&&ch!='n')//当后面的数字不为空并且没有换行时 {};//清除 //换行符进行输出 fputc(ch,copyptr);//之后进行复制 } else if(ch =='*')//如果时/* while((ch = fgetc(fptr))!=EOF &&ch!='*' || (ch=fgetc(fptr))!=EOF && ch!='/'); else { fputc('/',copyptr);//这步是什么意思,我不是很明白 fputc(ch,copyptr); } } else fputc(ch,copyptr); } fclose(fptr); fclose(copyptr); return 0; }



