Advertisement
yoyo106

search incomplete

Dec 16th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #define MAX 100
  5. typedef struct
  6. {
  7.     char fn[100];
  8.     char ln [100];
  9.     char no[100];
  10. }contact;
  11. FILE *fp;
  12. void search(int type);
  13. void main()
  14. {
  15.  
  16.  
  17.     int type,found;
  18.     puts("How do you want to search?\n0 - Search by first name.\n1 - Search by last name.\n2 - Search by number.");
  19.     do
  20.     {
  21.         scanf("%d",&type);
  22.         if (type==0||type==1||type==2)
  23.         found=search (type);
  24.     }
  25.     while (type>2);
  26. }
  27. int search(int type)
  28. {
  29.     fp = fopen("phonebook.txt","r");
  30.  
  31.     int flag=0,i;
  32.     char key[100];
  33.     if (type==0)
  34.     {
  35.         gets(key);
  36.         while (!feof)
  37.         {
  38.             //fscanf(fp,)
  39.         }
  40.     }
  41.     else if (type==1)
  42.     {
  43.         for (i=0;i<=3;i++)
  44.             if (strcmp(*(cont+i),key)=0)
  45.                 found=1;
  46.     }
  47.     else if (type==2)
  48.     {
  49.         for (i=0;i<=3;i++)
  50.             if (strcmp(*(cont+i),key)=0)
  51.                 found=1;
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement