Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- struct book
- {
- char authorName[128];
- char title[128];
- int catalogNumber;
- int price;
- };
- void loadBook(struct book *x)
- {
- printf("Podaj autora: ");
- scanf("%s", &(x->authorName));
- printf("Podaj nazwe ksiazki: ");
- scanf("%s", &(x->title));
- printf("Podaj nr katalogowy: ");
- scanf("%d", &(x->catalogNumber));
- printf("Podaj cene: ");
- scanf("%d", &(x->price));
- }
- void printBook(struct book *x)
- {
- printf("Autor: %s\n", x->authorName);
- printf("Tytul: %s\n", x->title);
- printf("Nr katalogowy: %d\n", x->catalogNumber);
- printf("Cena: %d\n", x->price);
- printf("\n\n");
- }
- int main(void)
- {
- int i;
- struct book books[3];
- for(i = 0; i < 3; i++)
- {
- loadBook(&books[i]);
- }
- for(i = 0; i < 3; i++)
- {
- printBook(&books[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement