Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6.  
  7.  
  8. struct Book{
  9. char name[50];
  10. float price;
  11. char aName[50];
  12. }typedef book;
  13.  
  14. void scanbarr(book* arr, int length, char* ref)
  15. {
  16. for(int i = 0 ; i < length ; i++)
  17. {
  18. book b = (*(arr+i));
  19. if (strcmp(b.aName,ref) == 0) {
  20. puts("found...");
  21. puts(b.name);
  22. break;
  23. }
  24. }
  25. puts("not found..");
  26. }
  27.  
  28. void main()
  29. {
  30. book b1 = {"Starwars",32,"George Lucas"};
  31. book b2 = {"Starwars II ",64,"George Lucas II"};
  32.  
  33. book* barr[5] = {};
  34. barr[0] = &b1;
  35. barr[1] = &b2;
  36. scanbarr(barr,2,"George Lucas");
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement