chapter 17) 구조체 배열을 초기화하고 출력
#include struct address { char name[20]; int age; char tel[20]; char addr[80]; }; int main(void){ struct address list[5] = { {"test1", 23, "111-1111", "core1"}, {"test2", 35, "222-2222", "core2"}, {"test3", 19, "333-3333", "core3"}, {"test4", 15, "444-4444", "core4"}, {"test5", 45, "555-5555", "core5"} }; for( int i= 0; i< 5; i++){ printf("%10s%5d%15s%20s\n", list[i].name, list[i].age, list[i].t..
2024. 10. 4.
chapter 17) 자기 참조 구조체로 list 만들기
#include struct list{ int num; struct list *next; }; int main(void){ struct list a = {10, 0}, b = {20,0}, c = {30,0}; struct list *head = &a, *current; a.next = &b, b.next = &c; printf("head -> num : %d\n", head -> num); printf("head -> next -> num : %d\n", head -> next -> num); printf("list all :"); current = head; while(current != NULL){ printf("%d ", current -> num); current = current -> next..
2024. 10. 3.