Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #include<stdlib.h>
- /*
- // Strucure de type article
- typedef struct{
- char libelle[19];
- int codeArticle, codeR;
- float prixU;
- struct article *suivant;
- }article;
- */
- // Structure de type rayon
- typedef struct{
- char nom[11];
- int codeRayon;
- struct rayon *rsuivant;
- }rayon;
- main(){
- /*Déclarations des fichiers*/
- FILE *fdat, *fdat2, *fres;
- fdat2 = fopen("produit.dat","r");
- fdat = fopen("rayon.dat","r");
- fres = fopen("ticket.res","w");
- /* Déclarations des données*/
- int cpt=1, i, choixRayon=0,n=1,quant,choixArt;
- // article *deb, *courant, *suivant;
- rayon *rdeb, *rcourant, *rsuivant;
- rdeb = malloc(sizeof(rayon));
- rcourant = rdeb;
- /*Lecture des rayons dans le premier fichier*/
- fscanf(fdat,"%d",&rcourant->codeRayon);
- while(!feof(fdat))
- {
- fscanf(fdat,"%10s",&rcourant->nom);
- rsuivant = malloc(sizeof(rayon));
- rcourant->rsuivant = rsuivant;
- cpt++;
- rcourant = rsuivant;
- fscanf(fdat,"%d",&rcourant->codeRayon);
- }
- cpt-=1;
- rcourant=rdeb;
- for(i=1;i<=cpt;i++)
- {
- rcourant=rcourant->rsuivant;
- }
- (*rcourant).rsuivant = NULL;
- //Lecture des articles dans le second fichier
- deb = malloc(sizeof(article));
- courant = deb;
- fscanf(fdat2,"",&courant->codeR);
- while(!feof(fdat2)){
- fscanf(fdat,"%5d%18s%4f",&courant->codeArticle, &courant->libelle, &courant->prixU);
- suivant = malloc(sizeof(article));
- courant->suivant = suivant;
- n++;
- courant = suivant;
- }
- n-=1;
- /*
- courant=deb;
- for(i=1;i<=cpt;i++)
- {
- courant=courant->suivant;
- }
- courant->suivant = NULL;
- */
- /*Interarction console*/
- printf("Votre magasin Colruyt vous souhaite la bienvenue !\n");
- printf("Commencez vos achats en choisissant un rayon !\n");
- rcourant=rdeb;
- for(i=1;i<=cpt;i++)
- {
- printf("%d : %10s\n",rcourant->codeRayon,rcourant->nom);
- rcourant=rcourant->rsuivant;
- }
- printf("Tapez le numero du rayon : \n");
- scanf("%d",&choixRayon);
- courant = deb;
- for(i=1;i<n;i++){
- if(courant->codeR == choixRayon){
- printf("%18s ",courant->libelle);
- }
- }
- printf("Tapez le numero de l'article : \n");
- scanf("%d", &choixArt);
- printf("En quelle quantité?\n");
- scanf("%d", &quant);
- fprintf(fres,"Colruyt\n");
- fprintf(fres,"+-------+------------------------+----------+--------+--------+---------+\n");
- fprintf(fres,"| N° art| Dénomination | Vidanges | Quant. | Prix U | Montant |\n");
- fprintf(fres,"+-------+------------------------+----------+--------+--------+---------+\n");
- for(i=1;i<cpt;i++){
- fprintf(fres,"| | | | | | |");
- }
- fprintf(fres,"+-------+------------------------+----------+--------+--------+---------+\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement