mercii bcp pour ta reponse ,mais malheureusement j' ai po bi1 compri comment faire...ben voila un bout de mon code...cé un projet de gestion pharmaceutique le prob ke j ai, cé ke je ve faire une modification du prix dans le fichier:
typedef struct medicament{
int code;
char designation[50];
char datevali[20];
int prix;
int quantirest;
struct medicament *pointeur;
}medicament;
medicament *premier=NULL;
void ajouter(medicament *premier,int code,char *datevali,char *desi,int prix,int quant)//ajouter un nouveau medicament
{
medicament *p=(medicament *)malloc(sizeof(medicament));
p->code=code;
strcpy(p->designation,desi);
strcpy(p->datevali,datevali);
p->prix=prix;
p->quantirest=quant;
p->pointeur=premier;
premier=p;
printf("ajout termin\202!!");
}
void modifierprix(medicament *premier,char *medic,int prix)//modification prix dans la memoire
{
medicament *p; p=(medicament *)malloc(sizeof(medicament));
while(p!=NULL)
{
if(strcmp(p->designation,medic)==0)
{ p->prix=prix;return ;}
else
p=p->pointeur;
}
}
void sauvegarderenstock(FILE * fichier,medicament *premier)//pour enregistrer le medicament ajouté dans un fichier
{
medicament *p=premier;
fichier=fopen("stockmedicament.txt","a+");
if(fichier!=NULL)
{
fprintf(fichier,"*************stockmedicament************");
while(p!=NULL)
{
fprintf(fichier,"========================================");
fprintf(fichier,"Nom du medicament:%s\nSon code:%d\nDate de validit\202:%s\nPrix:%d\nquantit\202 en stock:%d\n",p->designation,p->code,p->datevali,p->prix,p->quantirest);
fprintf(fichier,"=====================================");
p=p->pointeur;
}
fclose(fichier);
}
}
merciii d'avance pour votre aide
