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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
typedef struct adresse
{ int numr;
char nomr[20];
char nomv[20];
}ADR;
typedef struct contact
{
int ref;
char nom[20];
char prenom[20];
char sexe;
char date[10];
char lieu[20];
ADR adresse;
char pays[20];
int numerof;
int numerom;
}Contact;
FILE* fp;
typedef struct Cellule_Contact
{
Contact * c;
struct Cellule_Contact * suivant;
}Cellule;
//*************************************
Cellule * Creer_Cellule(Contact * Cont)
{
Cellule * N=NULL;
N=(Cellule*)malloc(sizeof(Cellule));
N->c=Cont;
N->suivant=NULL;
return N;
}
//*************************************
Cellule * Inserer_Contact_tete(Cellule * CL,Contact * Cont)
{Cellule * nouv=NULL;
nouv=Creer_Cellule(Cont);
if(CL==NULL)
return nouv;
else
nouv->suivant=CL;
return nouv;
}
Cellule * Charger_Contact_Dans_Liste(Cellule* LC,Contact * temp,FILE *fp)
{
fp=fopen("Contacts.txt","r");
if(fp==NULL)
printf("Ouverture impossible");
else
{while(fread((temp),sizeof(Contact),1,fp) && !feof(fp))
{
LC=Inserer_Contact_tete(LC,temp);
printf("%s",LC->c->nom);
}
fclose(fp);
}
return LC;}
void main()
{int N;Cellule * L=NULL;
printf("\n Bienvenue sur notre programme\n");
Contact temp;
int test;
//printf("\n\nEntrer le nombre de contacts que vous voulez saisir");
//scanf("%d",&N);
//Saisie_Carnet(N,temp);
L=Charger_Contact_Dans_Liste(L,&temp,fp);
//Afficher_Contacts_Liste(L);
printf("\n%d",L);
printf("%s",L->c->nom);
printf("\nL'adresse suivante est:%d",L->suivant);
L=L->suivant;
printf("\n%d",L);
printf("%s",L->c->nom);
printf("\nL'adresse suivante est:%d",L->suivant);
L=L->suivant;
printf("\n%d",L);
printf("\nL'adresse suivante est:%d",L->suivant);
L=L->suivant;
printf("\n%d",L);
printf("\n Le nom:%s",L->c->nom);
printf("Merci pour votre visite");
} |
Partager