Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1. int LectureFichierHisto(char *nomfichier, char *categ){
  2.     int ret=0;
  3.     float somme=0;
  4.     char ligne[TAILLE_LIGNE_HISTO];
  5.     Operation_t *operation = NULL;
  6.     FILE *fichier=fopen(nomfichier, "r");
  7.  
  8.     if(fichier !=NULL){
  9.         fgets(ligne,TAILLE_LIGNE_HISTO,fichier);
  10.         ligne[strlen(ligne)-1] = '\0';
  11.         while(!feof(fichier)){
  12.             operation=LireLigneHisto(ligne);
  13.             /*AfficherOperation(operation);*/
  14.             /*Decommenter quand lireligne histo marche puis quand estcategStat sera ecrit*/
  15.            
  16.             if(strcmp(operation->cat,categ) == 0){
  17.                 if(operation->operateur == '+'){
  18.                     somme+=operation->montant;
  19.                 }
  20.                 else{
  21.                     somme-=operation->montant;
  22.                 }
  23.                 AfficherOperation(operation);
  24.             }
  25.             fgets(ligne,TAILLE_LIGNE_HISTO,fichier);
  26.             ligne[strlen(ligne)-1] = '\0';
  27.         }
  28.         printf("[LectureFichierHisto] : somme pour la categ %s : %.2f",categ,somme);
  29.         fclose(fichier);
  30.     }
  31.     else{
  32.         ret = -1;
  33.     }
  34.     return ret;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement