Gestion d'un cabinet medical

Fermé
AydaNeji Messages postés 1 Date d'inscription dimanche 12 avril 2015 Statut Membre Dernière intervention 12 avril 2015 - 12 avril 2015 à 17:56
[Dal] Messages postés 6174 Date d'inscription mercredi 15 septembre 2004 Statut Contributeur Dernière intervention 2 février 2024 - 14 avril 2015 à 11:41
salut, mon probleme est comment supprimer un tel patient et de modifier ses données
merci d'avance
voici mon programme :



#include<stdio.h>
#include<conio.h>

struct adresse
{
int num;
char rue[15];
char ville[20];
};
struct Date
{
int jour;
int mois;
int annee;
};
struct medicament
{
int code;
int quantite;
char nom[20];
};
struct rendv
{
Date dater;
char etatrend;
} ;
struct patient
{ int num;
char nom[20];
char prenom[20];
char adr [30];
Date d_n;
char l_ness [20];
char etat [20];
rendv rd;
};



patient saisie_patient()
{
patient p;
printf("saisir le num: ");
scanf("%d",&p.num);
printf("saisir le nom : ");
scanf("%s",&p.nom);
printf("saisir le prenom : ");
scanf("%s",&p.prenom);
printf("saisir l'adr : ");
scanf("%s",&p.adr);
printf("saisir le date de naissance : ");
printf("saisir le jour de naissance : ");
scanf("%d",&p.d_n.jour);
printf("saisir le mois de naissance : ");
scanf("%d",&p.d_n.mois);
printf("saisir l annee de naissance : ");
scanf("%d",&p.d_n.annee);
printf("saisir le lieu de naissance : ");
scanf("%s",&p.l_ness);
printf("saisir l'etat : ");
scanf("%s",&p.etat);



return(p);

}
void ecrire_patient()
{ FILE*fp;
int rep;
patient p;
fp= fopen("patient.txt","a");
do
{
p=saisie_patient();
fwrite(&p,sizeof(patient),1,fp);
do{

printf("voulez vous ajouter un autre medicament 0:non,1:oui");
scanf("%d",&rep);
}while ((rep!=0)&&(rep!=1));
}while (rep==1);
fclose(fp);
}




void affiche_patient(patient p)
{
printf("num: %d \n",p.num);
printf("nom: %s \n",p.nom);
printf("prenom: %s \n",p.prenom);
printf("adresse: %s \n",p.adr);
printf("lieu de naissance: %s \n",p.l_ness);
printf("etat: %s \n",p.etat);
printf("date de naissance: \n");
printf(" jour: %d \n",p.d_n.jour);
printf(" mois: %d \n",p.d_n.mois);
printf(" annee: %d \n",p.d_n.annee);


}

void lire_patient()
{
FILE*fpt;

patient p;
fpt= fopen("patient.txt","r");
fread(&p,sizeof(patient),1,fpt);
while (!feof(fpt))
{
affiche_patient(p);
fread(&p,sizeof(patient),1,fpt);
}
fclose(fpt);
}
void ajout_patient()
{ FILE*fp;
int rep;
patient p;
fp= fopen("patient.txt","a");
do
{
p=saisie_patient();
fwrite(&p,sizeof(patient),1,fp);


printf("voulez vous ajouter un autre medicament 0:non,1:oui");
scanf("%d",&rep);

}while (rep==1);
fclose(fp);
}


medicament saisie_medicament()
{
medicament m;

printf("donner le code :");
scanf("%d",&m.code);
printf("donner la quantite :");
scanf("%d",&m.quantite);
printf("donner le nom :");
scanf("%s",&m.nom);

return(m);
}

void ecrire_medicament()
{
FILE*fm;
int rep;
medicament m;
fm=fopen("medicament.txt","a");
do{
m=saisie_medicament();
fwrite(&m,sizeof(medicament),1,fm);
do{
printf("voulez vous ajouter un autre medicament 0:non,1:oui");
scanf("%d",& rep);
}while ((rep!=0)&&(rep!=1));
}while (rep==1);
fclose(fm);
}


void affiche_medicament(medicament m)
{
printf("code : %d \n",m.code) ;
printf("quantité : %d \n",m.quantite);
printf("nom : %s \n",m.nom);
}
void lire_medicament()
{
FILE*fm;

medicament m;
fm= fopen("medicament.txt","r");
fread(&m,sizeof(medicament),1,fm);
while (!feof(fm))
{
affiche_medicament(m);
fread(&m,sizeof(medicament),1,fm);
}
}

void ajout_medicament()
{
FILE*fm;
int rep;
medicament m;
fm=fopen("medicament.txt","a");
do{
m=saisie_medicament();
fwrite(&m,sizeof(medicament),1,fm);

printf("voulez vous ajouter un autre medicament 0:non,1:oui");
scanf("%d",& rep);

}while (rep==1);
fclose(fm);
}


// int remove (char *nom) ;
// int rename(char *oldname, char *newname) ;//

int main()
{ patient p;
medicament m;
// p=saisie_patient();
// ecrire_patient();
// affiche_patient(p);
//lire_patient();
//ajout_patient();
m=saisie_medicament();
ecrire_medicament();
affiche_medicament(m);
ajout_medicament();
getch();

return 0;
A voir également:

1 réponse

[Dal] Messages postés 6174 Date d'inscription mercredi 15 septembre 2004 Statut Contributeur Dernière intervention 2 février 2024 1 083
14 avril 2015 à 11:41
Salut AydaNeji,

Avec quel genre de compilateur arrives-tu à compiler ce code ?

Sinon, lorsque tu postes du code sur le forum, utilise les balises code s'il te plaît, pour que ton code soit plus lisible.

Dal
0