Advertisement
wojtas626

[C] JiMP 10.3

Dec 9th, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.92 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. struct book
  6. {
  7.     char authorName[128];
  8.     char title[128];
  9.     int catalogNumber;
  10.     int price;
  11. };
  12.  
  13. void loadBook(struct book *x)
  14. {
  15.     printf("Podaj autora: ");
  16.     scanf("%s", &(x->authorName));
  17.     printf("Podaj nazwe ksiazki: ");
  18.     scanf("%s", &(x->title));
  19.     printf("Podaj nr katalogowy: ");
  20.     scanf("%d", &(x->catalogNumber));
  21.     printf("Podaj cene: ");
  22.     scanf("%d", &(x->price));
  23. }
  24.  
  25. void printBook(struct book *x)
  26. {
  27.     printf("Autor: %s\n", x->authorName);
  28.     printf("Tytul: %s\n", x->title);
  29.     printf("Nr katalogowy: %d\n", x->catalogNumber);
  30.     printf("Cena: %d\n", x->price);
  31.     printf("\n\n");
  32. }
  33.  
  34. int main(void)
  35. {
  36.     int i;
  37.     struct book books[3];
  38.     for(i = 0; i < 3; i++)
  39.     {
  40.         loadBook(&books[i]);
  41.     }
  42.  
  43.     for(i = 0; i < 3; i++)
  44.     {
  45.         printBook(&books[i]);
  46.     }
  47.  
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement