Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1. #include "MAJFacture.h"
  2. #include <stdio.h>
  3. #include <string>
  4. #include <stdlib.h>
  5.  
  6. Article lireArt(FILE *fe)
  7. {
  8.     Article art;
  9.     int lg ;
  10.  
  11.     fgets(art.Reference, 5, fe) ;
  12.     lg=strlen(art.Reference) ;
  13.     art.Reference[lg-1]='\0' ;
  14.  
  15.     fgets(art.Designation, 30, fe) ;
  16.     lg=strlen(art.Designation) ;
  17.     art.Designation[lg-1]= '\0' ;
  18.  
  19.     fscanf(fe, "%d", &art.Prix) ;
  20.     fscanf(fe, "%d", &art.Quantite) ;
  21.  
  22.     return art ;
  23. }
  24.  
  25. Article* chargeFarticle (FILE *fe, int* nbart)
  26. {
  27.     Article * art ;
  28.     int i = 0 ;
  29.  
  30.  
  31.     art = (Article)malloc(sizeof(Article));
  32.     if(art == NULL){
  33.         printf("Problème d'allocation sur art\n") ;
  34.         return ;
  35.     }
  36.  
  37.     for(i = 0; i < *nbart; i++ ){
  38.         *art[i] = lireArt(fe) ;
  39.     }
  40.  
  41.     return art ;
  42. }
  43.  
  44. void AffichArt(Article *tart, int nbart)
  45. {
  46.     int i ;
  47.  
  48.     for(i = 0; i < nbart ; i++ ){
  49.         printf("%c %c %d %d\n",art.Reference, art.Designation, art.Prix, art.Quantite);
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement