Advertisement
bartek27210

Untitled

Jan 11th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. typedef struct
  5. {
  6. char nazwisko[30];
  7. char tytul[50];
  8. int numer;
  9. int cena;
  10. }ksiazka;
  11.  
  12. void main()
  13. {
  14. ksiazka *egzemplarz=NULL;
  15. int i = 0, j = 0,k;
  16.  
  17. for (j; j < 2; j++)
  18. {
  19. egzemplarz = (ksiazka*)realloc(egzemplarz, (i + 1) * sizeof(ksiazka));
  20. fflush(stdin);
  21. scanf("%s", &egzemplarz[i].nazwisko);
  22. fflush(stdin);
  23. scanf("%s", &egzemplarz[i].tytul);
  24. fflush(stdin);
  25. scanf("%d", &egzemplarz[i].numer);
  26. fflush(stdin);
  27. scanf("%d", &egzemplarz[i].cena);
  28. printf("Nowa struktura\n");
  29. i++;
  30. }
  31.  
  32. for (k = 0; k < 2; k++)
  33. {
  34.  
  35. free(egzemplarz);
  36. }
  37.  
  38.  
  39. system("pause");
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement