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;
- FILE *fp;
- void search(int type);
- void main()
- {
- int type,found;
- puts("How do you want to search?\n0 - Search by first name.\n1 - Search by last name.\n2 - Search by number.");
- do
- {
- scanf("%d",&type);
- if (type==0||type==1||type==2)
- found=search (type);
- }
- while (type>2);
- }
- int search(int type)
- {
- fp = fopen("phonebook.txt","r");
- int flag=0,i;
- char key[100];
- if (type==0)
- {
- gets(key);
- while (!feof)
- {
- //fscanf(fp,)
- }
- }
- else if (type==1)
- {
- for (i=0;i<=3;i++)
- if (strcmp(*(cont+i),key)=0)
- found=1;
- }
- else 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