programmation modulaire en C
Bonsoir
j'ai un petit problème avec la gestion des fichiers de mon projet si vous pouvez m'aider SVP :)
voila j’essaie d’appelé une structure dans main.c depuis un autre mais le compilateur me détecte une erreur, ça me semble correct ce que j'ai fait mais je sais pas pourquoi ce ne marche pas :s
voila un bout de code
main.c
Code:
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
| #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#define FICHIER_DATA "data.bin"
#include "security.h"
#include "menu.h"
#include "update.h"
#include "controle.h"
#define MAX_PRODUIT 50
#define CASE_PETITE 10
#define CASE_MOYENNE 25
#define CASE_GRANDE 50
typedef struct
{
char nom[CASE_MOYENNE];
char ref_produit[CASE_PETITE];
//char fournisseur[20];
char categorie[CASE_MOYENNE];
char description[CASE_GRANDE];
int quantite;
float prix;
}Produit;
Produit tab_liste_produit[MAX_PRODUIT];
Produit un_produit;
... |
controle.h
Code:
int file_to_tab(void);
controle.c
Code:
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
| #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#include "controle.h"
#include "security.h"
#define FICHIER_DATA "data.bin"
int file_to_tab(void)
{
FILE *Fichier = NULL;
Fichier = fopen(FICHIER_DATA, "r");
Produit enrg;
int i=0;
while(fread(&enrg,sizeof(Produit),1,Fichier) != NULL)
{
strcpy(tab_liste_produit[i].nom,enrg.nom);
strcpy(tab_liste_produit[i].ref_produit,enrg.ref_produit);
strcpy(tab_liste_produit[i].categorie,enrg.categorie);
strcpy(tab_liste_produit[i].description,enrg.description);
tab_liste_produit[i].quantite = enrg.quantite;
tab_liste_produit[i].prix = enrg.prix;
i++;
}
fclose(Fichier);
return i;
} |
le problème est dans la ligne 12 du fichier controle.c
les erreurs donné par le compilateur
Citation:
C:\Users\M3-X\Documents\lp-i\Tp - Algo - C\Projet Gestion De Stock\Projet\Gestion De Stock\controle.c||In function 'file_to_tab':|
C:\Users\M3-X\Documents\lp-i\Tp - Algo - C\Projet Gestion De Stock\Projet\Gestion De Stock\controle.c|13|error: unknown type name 'Produit'|
C:\Users\M3-X\Documents\lp-i\Tp - Algo - C\Projet Gestion De Stock\Projet\Gestion De Stock\controle.c|16|error: 'Produit' undeclared (first use in this function)|
C:\Users\M3-X\Documents\lp-i\Tp - Algo - C\Projet Gestion De Stock\Projet\Gestion De Stock\controle.c|16|note: each undeclared identifier is reported only once for each function it appears in|
C:\Users\M3-X\Documents\lp-i\Tp - Algo - C\Projet Gestion De Stock\Projet\Gestion De Stock\controle.c|18|error: 'tab_liste_produit' undeclared (first use in this function)|
C:\Users\M3-X\Documents\lp-i\Tp - Algo - C\Projet Gestion De Stock\Projet\Gestion De Stock\controle.c|18|error: request for member 'nom' in something not a structure or union|
C:\Users\M3-X\Documents\lp-i\Tp - Algo - C\Projet Gestion De Stock\Projet\Gestion De Stock\controle.c|19|error: request for member 'ref_produit' in something not a structure or union|
C:\Users\M3-X\Documents\lp-i\Tp - Algo - C\Projet Gestion De Stock\Projet\Gestion De Stock\controle.c|20|error: request for member 'categorie' in something not a structure or union|
C:\Users\M3-X\Documents\lp-i\Tp - Algo - C\Projet Gestion De Stock\Projet\Gestion De Stock\controle.c|21|error: request for member 'description' in something not a structure or union|
C:\Users\M3-X\Documents\lp-i\Tp - Algo - C\Projet Gestion De Stock\Projet\Gestion De Stock\controle.c|22|error: request for member 'quantite' in something not a structure or union|
C:\Users\M3-X\Documents\lp-i\Tp - Algo - C\Projet Gestion De Stock\Projet\Gestion De Stock\controle.c|23|error: request for member 'prix' in something not a structure or union|
||=== Build finished: 9 errors, 0 warnings (0 minutes, 1 seconds) ===|