zay_nab
Messages postés2Date d'inscriptiondimanche 18 mai 2014StatutMembreDernière intervention18 mai 2014
-
Modifié par zay_nab le 19/05/2014 à 00:13
GRDX
Messages postés128Date d'inscriptionsamedi 10 août 2013StatutMembreDernière intervention 9 juin 2014
-
19 mai 2014 à 00:14
Bonjour,
j'ai un problème concernant mon Mini projet en Langage C, j'arrive pas a terminé le programme, car je suis débutante en programmation et je ne sais pas comment faire une relation entre les structure
et j'espère que vous me donnez un coup de main et merci
voilà mon projet
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//**!!!!!!!!!!!!!!!!!!!!!!déclaration des structures!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
typedef struct Client{
int Id_client;
char nom [30];
char prenom[30];
char profession[30];
char Num_tel[30];
struct Client *suivant;
}Client;
typedef struct Compte{
int *Id_compte;
int *Id_client;
float Solde_base ;
}Compte;
//*********************Chercher Un Client Dans toute la liste par Identifiant************************
Client *ChercherClient(Client *liste,int Id_client){
Client *tmp;
tmp=liste;
while(tmp!=NULL){
if(tmp->Id_client==Id_client){
return tmp;
}
tmp=tmp->suivant;
}
return NULL;
}
//*****************Ajouter un client en tete de liste************************
Client* ajouterClientEnTete(Client *liste){
Client *nvClient=(Client*)malloc(sizeof(Client));
Client *tmp;
int Id_client;
printf("donner le Identifiant de Client : ");
scanf("%d",&Id_client);
/*recherche si le client existe ou non*/
tmp=ChercherClient(liste,Id_client);
if(tmp!=NULL)
{
printf("\nCe Client existe deja !!\n");
return liste;
}
nvClient->Id_client=Id_client;
printf("Nom : ");
scanf("%s",nvClient->nom);
printf("Prenom : ");
scanf("%s",nvClient->prenom);
printf("Profession : ");
scanf("%s",nvClient->profession);
printf("numero de tel : ");
scanf("%s",nvClient->Num_tel);
nvClient->suivant=liste;
return liste;}
//**************AJOUTER un Client à la fin liste****************************
Client* ajouterClientEnFin(Client *liste){
Client *nvClient=(Client*)malloc(sizeof(Client));
Client *tmp;
int Id_client;
printf("donner le Identifiant de Client : ");
scanf("%d",&Id_client);
/*recherche si le client existe ou non*/
tmp=ChercherClient(liste,Id_client);
if(tmp!=NULL)
{
printf("\nCe Client existe deja !!\n");
return liste;
}
nvClient->Id_client=Id_client;
printf("Nom : ");
scanf("%s",nvClient->nom);
printf("Prenom : ");
scanf("%s",nvClient->prenom);
printf("Profession : ");
scanf("%s",nvClient->profession);
printf("numero de tel : ");
scanf("%s",nvClient->Num_tel);
//*****************************ENREGISTRER la liste des Clients***************************************
void enregistrer(Client *liste){
Client *tmp;
char fichier[]={"Client.doc"};
tmp=liste;
FILE* f;
f=fopen(fichier,"w");
while(tmp!=NULL){
fprintf(f,"%d\t%s\t%s\t%s\t%s\n",tmp->Id_client,tmp->nom,tmp->prenom,tmp->profession,tmp->Num_tel);
tmp=tmp->suivant;
}
fclose(f);
}
//***************************Afficher le contenu de la liste des clients (chainée)***********************************
void afficher(Client *liste){
Client *tmp;
tmp=liste;
while(tmp!=NULL)
{
printf("%d\t%s\t%s\t%s\t%s\n",tmp->Id_client,tmp->nom,tmp->prenom,tmp->profession,tmp->Num_tel);
tmp=tmp->suivant;
}
}
//*****************************recherche si le client à déjà un compte*****************************
Compte *RechercheCompte(Compte *liste2,int Id_client){
Compte *tmp;
tmp=liste2;
while(tmp!=NULL){
if(tmp->Id_client==Id_client){
return tmp;
}
tmp=tmp->suivant;
}
return NULL;
}
//****************************Creer un nouveau compte************************************************
Compte *creerCompte(Compte *liste2,Client *liste){
int Id_client;
Compte *nvCompte=(Compte*)malloc(sizeof(Compte));
int tmp3;
printf("donnez le id_client");
scanf("%d",&Id_client);
Client *tmp=ChercherClient(liste,Id_client);
Compte *tmp2=RechercheCompte(liste2,Id_compte);
if (tmp!=NULL){
if(tmp2!=NULL){
printf("tu as déjà autre compte ;est ce que tu veux ouvrir un autre??\n");
printf("1:oui\n");
printf("2:non\n");
scanf("%d",&tmp2);
if(tmp3=1||tmp3!=2 ){ break;}
}
}
nvCompte->Id_compte=Id_compte;
printf("solde de base: ");
scanf("%s",nvCompte->Solde_base);
nvCompte->suivant=liste2;
return liste2; }