1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <string.h> struct Book { int number; char title[100]; }; int main(void) { struct Book *p; p = (struct Book *)malloc(2 * sizeof(struct Book)); if (p == NULL) { printf("¸Þ¸ð¸® ÇÒ´ç ¿À·ù\n"); exit(1); } p[0].number = 1; // (*p).number = 1 strcpy(p[0].title, "C Programming"); p[1].number = 2; // (*p+1).number = 2 strcpy(p[1].title, "Data Structure"); free(p); return 0; } | cs |