Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <malloc.h>
- #include <string.h>
- #include <windows.h>
- /**/
- #define MAX_STR_LENGHT 128
- typedef struct {
- char* autor;
- char* name;
- int str;
- }book;
- int main() {
- int i = 0;
- book book[5];
- for (int i = 0; i < 5; ++i) {
- printf("Pola dlya knigi %d.\n", i + 1);
- printf("Vvedite avtora -> ");
- book[i].autor = (char*)malloc(sizeof(*book[i].autor) * MAX_STR_LENGHT);
- scanf_s("%s", book[i].autor, strlen(book[i].autor));
- printf("Nazvanie knigi -> ");
- book[i].name = (char*)malloc(sizeof(*book[i].name) * MAX_STR_LENGHT);
- scanf_s("%s", book[i].name, strlen(book[i].name));
- printf("Vvedite kollichestvo stranic -> ");
- scanf_s("%d", &book[i].str);
- }
- printf("%10s %10s %5s %10s\n\n", "autor", "name", "str");
- printf("\nVvedennye dannye:\n");
- for (int i = 0; i < 5; ++i) {
- printf("%10d %10s %5s %10d", i + 1, book[i].autor, book[i].name, book[i].str);
- }
- system("pause");
- }
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement