typedef structure de données
salut,
le code suivant est executable
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 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
| #include<stdio.h>
#include<stdlib.h>
#include<conio.h>
struct adresse
{int num;
char rue[50];
int codepostal;
char ville[50];
};
struct date
{int jour;
int mois;
int anne;
};
struct fiche
{
char nom[50];
char prenom[50];
int telephonne;
struct adresse ad;
struct date da;
};
typedef struct fiche H;
void lirefiche(H *F)
{
printf("donner le nom :");
scanf("%s",F->nom);
printf("donner le prenom :");
scanf("%s",F->prenom);
printf("donner num :");
scanf("%d",&F->ad.num);
printf("donner le codepostale :");
scanf("%d",&F->ad.codepostal);
printf("donner rue :");
scanf("%s",F->ad.rue);
printf("donner la ville :");
scanf("%s",F->ad.ville);
printf("donner la date :");
scanf("%d%d%d",&F->da.jour,&F->da.mois,&F->da.anne);
}
void Affich_fiche(H F)
{
printf("le nom est %s ",F.nom);
printf("\nle prenom est %s",F.prenom);
printf("\nle num est %d ",F.ad.num);
printf("\nle codepostal est %d",F.ad.codepostal);
printf("\nle rue est %s ",F.ad.rue);
printf("\nla ville est %s",F.ad.ville);
printf("\nla date(jour,mois,anné) est %d %d %d",F.da.jour,F.da.mois,F.da.anne);
}
void main()
{
H F;
lirefiche(&F);
Affich_fiche(F);
getch();
} |
je veux faire une petite modification avec l'utilisation de typedef
mais ca marche pas
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 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
| #include<stdio.h>
#include<stdlib.h>
#include<conio.h>
typedef struct
{int num;
char rue[50];
int codepostal;
char ville[50];
}adresse;
typedef struct
{int jour;
int mois;
int anne;
}date;
typedef struct
{
char nom[50];
char prenom[50];
int telephonne;
adresse ad;
date da;
}fiche;
fiche H;
void lirefiche(H *F)
{
printf("donner le nom :");
scanf("%s",F->nom);
printf("donner le prenom :");
scanf("%s",F->prenom);
printf("donner num :");
scanf("%d",&F->ad.num);
printf("donner le codepostale :");
scanf("%d",&F->ad.codepostal);
printf("donner rue :");
scanf("%s",F->ad.rue);
printf("donner la ville :");
scanf("%s",F->ad.ville);
printf("donner la date :");
scanf("%d%d%d",&F->da.jour,&F->da.mois,&F->da.anne);
}
void Affich_fiche(H F)
{
printf("le nom est %s ",F.nom);
printf("\nle prenom est %s",F.prenom);
printf("\nle num est %d ",F.ad.num);
printf("\nle codepostal est %d",F.ad.codepostal);
printf("\nle rue est %s ",F.ad.rue);
printf("\nla ville est %s",F.ad.ville);
printf("\nla date(jour,mois,anné) est %d %d %d",F.da.jour,F.da.mois,F.da.anne);
}
void main()
{
H F;
lirefiche(&F);
Affich_fiche(F);
getch();
} |
pouvez vous me corriger avec l'utilisation de typedef
merci d'avance