编译第一步:去源代码(C)注释

 

#include<stdio.h>

 

 

#include<stdlib.h>

 

 

 

 

main()

 

 

{

 

 

         char ch1,ch2,ch3,ch4;

 

 

         FILE *fp1,*fp2;

 

 

          if((fp1=fopen("D:\\c programs\\常见题\\input.txt","r"))==NULL)

 

 

         {

 

 

                   printf("cann't open the input file\n");

 

 

                   exit(1);

 

 

         }

 

 

         if((fp2=fopen("D:\\c programs\\常见题\\output.txt","w"))==NULL)

 

 

         {

 

 

                   printf("cann't open the output file\n");

 

 

                   exit(1);

 

 

         }

 

 

        

 

 

         ch1=fgetc(fp1);

 

 

         ch2=fgetc(fp1);

 

 

         while(!feof(fp1))

 

 

         {

 

 

                   if('/'==ch1 && '/'==ch2)

 

 

//这里注意,判断条件要细分好,在设及到条件分支语句时,

 

 

//要注意,每个分支都要单独的测试到,会更容易维护

 

 

                   {

 

 

 

 

                            ch3=fgetc(fp1);

 

 

                            while(!feof(fp1))

 

 

                            {

 

 

                                     if(10==ch3)

 

 

                                     {

 

 

                                               fputc(ch3,fp2);

 

 

                                               break;

 

 

                                     }

 

 

                                     else

 

 

                                     {

 

 

                                               ch3=fgetc(fp1);

 

 

                                     }

 

 

                            }

 

 

                            ch1=fgetc(fp1);

 

 

                            ch2=fgetc(fp1);

 

 

                   }

 

 

 

 

                   if('/'==ch1 && '*'==ch2)

 

 

                   {

 

 

                            ch3=fgetc(fp1);

 

 

                            ch4=fgetc(fp1);

 

 

                            while(!feof(fp1))

 

 

                            {

 

 

                                     if('*'==ch3 && '/'==ch4)

 

 

                                     {

 

 

                                               ch1=fgetc(fp1);

 

 

                                               ch2=fgetc(fp1);

 

 

                                               break;

 

 

                                     }

 

 

                                     else

 

 

                                     {

 

 

                                               ch3=ch4;

 

 

                                               ch4=fgetc(fp1);

 

 

                                     }

 

 

                            }

 

 

                   }

 

 

 

 

                   else

 

 

                   {

 

 

                            fputc(ch1,fp2);

 

 

                            ch1=ch2;

 

 

                            ch2=fgetc(fp1);

 

 

                   }

 

 

         }

 

 

         fputc(ch1,fp2);

 

 

         fclose(fp1);

 

 

         fclose(fp2);

 

 

         return 1;

 

 

}

 

 

你可能感兴趣的:(style,职场,源代码,休闲,blank)