Précédent   Forum du club des développeurs et IT Pro > C et C++ > C > Débuter
Débuter Forum d'entraide pour débuter en langage C. Avant de poster -> FAQ C
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 23/12/2012, 21h58   #1
matt36295
Invité régulier
 
Inscription : décembre 2009
Messages : 33
Détails du profil
Informations forums :
Inscription : décembre 2009
Messages : 33
Points : 9
Points : 9
Par défaut 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
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) ===|
matt36295 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/12/2012, 08h38   #2
_-Slash-_
Membre éprouvé
 
Inscription : juillet 2006
Messages : 322
Détails du profil
Informations forums :
Inscription : juillet 2006
Messages : 322
Points : 422
Points : 422
A première vue ta structure Produit n'est déclarée que dans le main.c il faudra l'écrire dans un .h et l'inclure dans controle.c
_-Slash-_ est déconnecté   Envoyer un message privé Réponse avec citation 10
Réponse Cette discussion est résolue.
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 14h30.


 
 
 
 
Partenaires

Hébergement Web