作者在 2014-06-05 14:18:25 发布以下内容
#include<stdio.h>
int main()
{
FILE *fp_read,*fp_write;
fp_read=fopen("in.cpp","r");
fp_write=fopen("out.cpp","w");
bool yinhao=false;
char c;
while(!feof(fp_read)){
c=fgetc(fp_read);
if(c=='"') yinhao=!yinhao;
if('/'==c){
if(yinhao){
fputc(c,fp_write);
}
else{
c=fgetc(fp_read);
if(c=='/'){
while(c!='\n') c=fgetc(fp_read);
}
if(c=='*'){
char old;
old=fgetc(fp_read);
for(;;){
c=fgetc(fp_read);
if(old=='*'&&c=='/') break;
old=c;
}
}
}
}
else{
fputc(c,fp_write);
}
}
fclose(fp_read);
fclose(fp_write);
}