1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
   | #include <stdio.h>
#include <unistd.h>
#include <errno.h>
 
int main(void)
{
 
char ligne[3000];
FILE* fIn; 
FILE* fOut;
int position,j,type_ligne;
extern int errno; 
 
if((fIn= fopen("YTOPTIC.D", "rb")) == NULL) // ouverture du fichier source
         {
         printf("erreur, mauvais fichier source rentré");      
         system("pause"); 
         return (1);
         }  
 
if((fOut = fopen("optic.tmp", "w")) == NULL) //ouverture du fichier destination
         {
         printf("erreur, mauvais fichier destination entré");      
         fclose(fIn);
         return (1);
         }
 
while(fgets(ligne, sizeof ligne, fIn)!=NULL) 
          {type_ligne=0;
 
 
          if(((int)ligne[4]==49 && (int)ligne[5]==57 )|| ((int)ligne[4]==50 && (int)ligne[4]==48))
            {
            type_ligne=1;
            }
 
           switch(type_ligne)
 
                 {case 1:                                                                                  
                  for(j=0;j<90;j++)
                  {
                  putc(ligne[position],fOut);
                  if (j==77 /*|| j==18 || j==33 || j==37*/)fprintf(fOut,";");
                  position++;
                  }
                  fprintf(fOut,";");                                                                                           fprintf(fOut,"%d",errno); 
                  fprintf(fOut,"\n");
                  break;
 
                  }
          }
 
if(feof(fOut)) fprintf(fOut,"fin de fichier rencontré");
else fprintf(fOut,"erreur");       
} | 
Partager