#include <stdio.h>
#include <stdlib.h>
typedef struct booklist
{
char author[20];
char title[50];
int page;
} BookList;
void BookInfo(BookList *pbook)
{
printf("author: "); scanf("%s", pbook->author);
printf("title: "); scanf("%s", pbook->title);
printf("page: "); scanf("%d", &pbook->page);
}
void ShowBookInfo(BookList pbook)
{
printf("author: %s \n", pbook.author);
printf("title: %s \n", pbook.title);
printf("page: %d \n", pbook.page);
}
int main(void)
{
BookList *book = (BookList *)malloc(sizeof(BookList) * 3);
int i;
printf("====Book Info Input==== \n");
for (i = 0; i < 3; i++)
BookInfo(&book[i]);
printf("\n");
printf("====Book Info Output==== \n");
for (i = 0; i < 3; i++)
{
printf("book%d \n", i + 1);
ShowBookInfo(book[i]);
}
free(book);
return 0;
}
'SW Study > 윤성우 C 프로그래밍' 카테고리의 다른 글
도전! 프로그래밍4 도전4 (0) | 2019.10.10 |
---|---|
도전! 프로그래밍4 도전3 (0) | 2019.10.10 |
도전! 프로그래밍4 도전1 (0) | 2019.10.10 |
도전! 프로그래밍3. 도전 6 (0) | 2019.10.02 |
도전! 프로그래밍3. 도전 5 (0) | 2019.10.02 |