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
| #include <stdio.h>
typedef char byte;
struct journal {
char Z1 [14];
char Z2 [6];
char Z3 [13];
char Z4 [3];
char Z5 [2];
char Z6 [3];
char Z7 [23];
char Z8 [3];
char Z9 [23];
char Z10 [117];
char Z11 [23];
}; /* definition de la structure */
main (int argc,char *argv[])
{
FILE *entree, *sortie ; /* pointeurs sur fichier */
struct journal J1,*pt1; /* declaration du journal */
long ptr_courant;
int n =1;
int cpt =0;
int C3B;
C3B=0x3B;
if ((entree = fopen(argv[1],"r")) == (FILE *) NULL)
{
fprintf( stderr,"Ouverture du fichier impossible %c \n",*entree);
exit (1);
}
/* fprintf( stdout,"Ouverture du fichier %s \n ",&entree); */
/* Ouverture du fichier a ecrire */
if ((sortie = fopen(argv[2],"w")) == NULL)
{
fprintf(stderr ,"Ouverture du fichier impossible \n",sortie);
exit (1);
}
/* Lecture et traitement du fichier */
while (n == 1 )
{
{
ptr_courant = ftell (entree); /* & au pointeur du debut enreg */
fseek (entree,ptr_courant,SEEK_SET) ;/* deplacement par rap &debut*/
fwrite ((char *) & J1,sizeof(struct journal),1,sortie);
fputc (C3B, sortie);
cpt=cpt+1;
}
n = fread ((char *)&J1,sizeof (struct journal),1,entree);
}
/* printf ( "nombre de transactions rencontrées :%d \n ",cpt ); */
/* Fermeture des fichiers */
fflush(sortie);
fclose(entree);
fclose(sortie);
} |
Partager