Advertisement
Guest User

Untitled

a guest
Oct 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <iostream>
  5. #include <stdio.h>
  6. #include <string.h>
  7. using namespace std;
  8. struct ksiazka
  9. {
  10. int l_stron;
  11. char tytul[30];
  12. char autor[30];
  13. };
  14.  
  15.  
  16.  
  17. void AlokacjaK(ksiazka ***tab, int ile)
  18. {
  19. if (tab==NULL)
  20. {
  21. puts("error");
  22. }
  23. (*tab) = (ksiazka**)malloc(ile*sizeof(ksiazka*));
  24. for (int i = 0; i < ile, i++)
  25. {
  26. (*tab)[i] = (ksiazka*)malloc(sizeof(ksiazka));
  27. }
  28. }
  29.  
  30.  
  31. void DodajK( ksiazka ***tab, int ile)
  32. {
  33. for(int i=0; i<ile; i++) {
  34. strcpy((*tab)[i]->l_stron,200);
  35. strcpy((*tab)[i]->stytul,"Pamietnik");
  36. strcpy((*tab)[i]->autor, "Jan Stefan");
  37. }
  38. }
  39.  
  40. void PokazK( ksiazka ***tab, int ile)
  41. {
  42. for(int i=0; i<ile; i++) {
  43. printf("Ksiazki seria nr: %d \n",i+1);
  44. printf("Liczba stron: %s \n",(*tab)[i]->l_stron);
  45. printf("Pracownik ochrony: %s \n",(*tab)[i]->tytul);
  46. printf("Pracownik normalny: %s \n \n",(*tab)[i]->autor);
  47. }
  48. }
  49.  
  50. void UsunK( ksiazka **tab) {
  51. free(*tab);
  52. }
  53.  
  54. int main()
  55. {
  56.  
  57. int ile;
  58. printf("Podaj liczbe jednostek sklepu do wyswietlenia:\n");
  59. scanf("&d",&ile);
  60.  
  61. ksziaka **ks = NULL;
  62.  
  63. AlokacjaK(&ks,ile);
  64. DodajK(&ks,ile);
  65. PokazK(&ks,ile);
  66. UsunK(&ks,ile);
  67.  
  68.  
  69.  
  70. return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement