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
| #include<stdio.h>
#include<conio.h>
struct contact
{
char nom[20];
char prenom[20];
char groupe[20];
};
void afficher(struct contact t[10],int i,int n);
void remp(struct contact t[10],int *i);
void main()
{
struct contact t[10];
int i,n;
printf("entrez le nombre de contact");
scanf("%d",&n);
for(i=0;i<n;i++)
remp(t,&i);
for(i=0;i<n;i++)
afficher(t,i,n);
getch();
}
//==============================================================================
void remp(struct contact t[10],int *i)
{
int g;
printf("entrez le nom");
scanf("%s",t[*i].nom);
printf("\n entrez le prenom");
scanf("%s",t[*i].prenom);
printf("1- Amis 2-famille 3-Vip");
scanf("%d",&g);
if(g==1)
t[*i].groupe=="Amis";
else if(g==2)
t[*i].groupe=="famille";
else
t[*i].groupe=="Vip";
}
//==============================================================================
void afficher(struct contact t[10],int i,int n)
{
printf("%s\n",t[i].nom);
printf("%s\n",t[i].prenom);
printf("%s\n",t[i].groupe);
} |