Advertisement
yoyo106

search phonebook incomplete

Dec 15th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.24 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. void search(char *key, int type, contact entry);
  12. int main()
  13. {
  14.     contact i,t1,t2,t3;
  15.     contact entry[500];
  16.     for (i=0;i<n;i++)
  17.     {
  18.         gets(t1.fn);
  19.         gets(t1.ln);
  20.         gets(t1.no);
  21.         gets(t2.fn);
  22.         gets(t2.ln);
  23.         gets(t2.no);
  24.         gets(t3.fn);
  25.         gets(t3.ln);
  26.         gets(t3.no);
  27.     }
  28.     char *key;
  29.     int type,value;
  30.     puts("How do you want to search?\n0 - Search by first name.\n1 - Search by last name.\n2 - Search by number.");
  31.     do
  32.     {
  33.         scanf("%d",&value);
  34.         if (value==0||value==1||value==2)
  35.         search (key,value,entry);
  36.     }
  37.     while (value>2);
  38. }
  39. void search(key[100],type,entry)
  40. {
  41.     int flag=0,i;
  42.     if (type==0)
  43.     {
  44.         for (i=0;i<=3;i++)
  45.             if (strcmp(*(cont+i),key)=0)
  46.                 found=1;
  47.     }
  48.     if (type==1)
  49.     {
  50.         for (i=0;i<=3;i++)
  51.             if (strcmp(*(cont+i),key)=0)
  52.                 found=1;
  53.     }
  54.     if (type==2)
  55.     {
  56.         for (i=0;i<=3;i++)
  57.             if (strcmp(*(cont+i),key)=0)
  58.                 found=1;
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement