struct alloc memory
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 30 31 32 | #include <stdio.h> #include <stdlib.h> struct Phone { int areacode; unsigned long long int number; }; struct Person { char name[20]; int age; struct Phone *phone; }; int main (void) { struct Person *p1 = calloc (1, sizeof (struct Person)); p1->phone = calloc (1, sizeof (struct Phone)); p1->phone->areacode = 82; p1->phone->number = 30545671234; printf("%d %llu\n", p1->phone->areacode, p1->phone->number); free (p1->phone); free (p1); return 0; } | cs |
0 개의 댓글:
댓글 쓰기