Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- typedef struct phone
- {
- char nom[100];
- int num;
- }phone;
- int main()
- {
- phone *t,*p,*q;
- int n,i,k,j,c;
- char name[100];
- printf("Saisir N :\n");
- t=(phone*)malloc(n*sizeof(phone));
- scanf("%d",&n);
- j=n;
- q=t;
- i=0;
- while(j)
- {
- printf("Saisir le nom et le numero : \n");
- scanf("%s %d",q->nom,&t[i].num);
- q++;
- i++;
- j--;
- }
- for(j=0,c=0;j<n;j++)
- {
- printf("Saisir un nom a chercher : ");
- scanf("%s",name);printf("\n");
- for(p=t;p<t+n;p++)
- {
- if(strcmp(p->nom,name)==0)
- {
- printf("%s=%d",p->nom,p->num);c=1;break;
- }
- else
- c=0;
- }
- if(c==0)
- printf("Not found\n");
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement