Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int LectureFichierHisto(char *nomfichier, char *categ){
- int ret=0;
- float somme=0;
- char ligne[TAILLE_LIGNE_HISTO];
- Operation_t *operation = NULL;
- FILE *fichier=fopen(nomfichier, "r");
- if(fichier !=NULL){
- fgets(ligne,TAILLE_LIGNE_HISTO,fichier);
- ligne[strlen(ligne)-1] = '\0';
- while(!feof(fichier)){
- operation=LireLigneHisto(ligne);
- /*AfficherOperation(operation);*/
- /*Decommenter quand lireligne histo marche puis quand estcategStat sera ecrit*/
- if(strcmp(operation->cat,categ) == 0){
- if(operation->operateur == '+'){
- somme+=operation->montant;
- }
- else{
- somme-=operation->montant;
- }
- AfficherOperation(operation);
- }
- fgets(ligne,TAILLE_LIGNE_HISTO,fichier);
- ligne[strlen(ligne)-1] = '\0';
- }
- printf("[LectureFichierHisto] : somme pour la categ %s : %.2f",categ,somme);
- fclose(fichier);
- }
- else{
- ret = -1;
- }
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement