Advertisement
Guest User

Untitled

a guest
Dec 1st, 2015
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <malloc.h>
  5. #include <string.h>
  6. #include <windows.h>
  7.  
  8. /**/
  9.  
  10. #define MAX_STR_LENGHT 128
  11.  
  12. typedef struct {
  13. char* autor;
  14. char* name;
  15. int str;
  16. }book;
  17.  
  18. int main() {
  19. int i = 0;
  20. book book[5];
  21.  
  22. for (int i = 0; i < 5; ++i) {
  23. printf("Pola dlya knigi %d.\n", i + 1);
  24.  
  25. printf("Vvedite avtora -> ");
  26. book[i].autor = (char*)malloc(sizeof(*book[i].autor) * MAX_STR_LENGHT);
  27. scanf_s("%s", book[i].autor, strlen(book[i].autor));
  28.  
  29. printf("Nazvanie knigi -> ");
  30. book[i].name = (char*)malloc(sizeof(*book[i].name) * MAX_STR_LENGHT);
  31. scanf_s("%s", book[i].name, strlen(book[i].name));
  32.  
  33. printf("Vvedite kollichestvo stranic -> ");
  34. scanf_s("%d", &book[i].str);
  35. }
  36. printf("%10s %10s %5s %10s\n\n", "autor", "name", "str");
  37. printf("\nVvedennye dannye:\n");
  38. for (int i = 0; i < 5; ++i) {
  39. printf("%10d %10s %5s %10d", i + 1, book[i].autor, book[i].name, book[i].str);
  40. }
  41.  
  42. system("pause");
  43. }
  44. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement