Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define MAX 100
- typedef struct
- {
- char fn[100];
- char ln [100];
- char no[100];
- }contact;
- void search(char *key, int type, contact entry);
- int main()
- {
- contact i,t1,t2,t3;
- contact entry[500];
- for (i=0;i<n;i++)
- {
- gets(t1.fn);
- gets(t1.ln);
- gets(t1.no);
- gets(t2.fn);
- gets(t2.ln);
- gets(t2.no);
- gets(t3.fn);
- gets(t3.ln);
- gets(t3.no);
- }
- char *key;
- int type,value;
- puts("How do you want to search?\n0 - Search by first name.\n1 - Search by last name.\n2 - Search by number.");
- do
- {
- scanf("%d",&value);
- if (value==0||value==1||value==2)
- search (key,value,entry);
- }
- while (value>2);
- }
- void search(key[100],type,entry)
- {
- int flag=0,i;
- if (type==0)
- {
- for (i=0;i<=3;i++)
- if (strcmp(*(cont+i),key)=0)
- found=1;
- }
- if (type==1)
- {
- for (i=0;i<=3;i++)
- if (strcmp(*(cont+i),key)=0)
- found=1;
- }
- if (type==2)
- {
- for (i=0;i<=3;i++)
- if (strcmp(*(cont+i),key)=0)
- found=1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement