Advertisement
GrimHansl

search

Mar 15th, 2021
1,561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. void search(list cur)
  2. {
  3.     int maxYear = 0;    //
  4.     char inputName[50]; //
  5.     DataType book;      //
  6.     system ("CLS");
  7.     if(cur == NULL)
  8.     {
  9.        printf("List is empty\n");
  10.        getchar();
  11.        return;
  12.     }
  13.      
  14.     printf("Search year fixed, since 2001\n\n");
  15.     printf("Author's last name: ");
  16.     scanf("%s", inputName);
  17.     getchar();
  18.     while(cur)
  19.     {
  20.         if((strcmp(inputName, cur->data.author) == 0) && cur->data.yearOfPublication > 2000)
  21.         {
  22.             maxYear = cur->data.yearOfPublication;
  23.             book = cur->data;
  24.             printf("\n--------------------\n");
  25.             printData(book);
  26.             printf("\n--------------------\n");
  27.        }
  28.        cur = cur->next;
  29.     }
  30.    
  31.     if(maxYear == 0)
  32.     {
  33.         printf("There are no such records\n"); 
  34.     }  
  35.     printf("---\nPress any key to continue . . ."); getchar();
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement