| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <stdio.h> // 2차원 공간의 점을 구조체로 나타낸다. struct point { int x; int y; }; int main(void) { struct point p = { 1, 2 }; // ① struct point q = { .y = 2,.x = 1 }; // ② struct point r = p; // ③ r = (struct point) { 1, 2 }; // ④ C99 버전 printf("p=(%d, %d) \n", p.x, p.y); printf("q=(%d, %d) \n", q.x, q.y); printf("r=(%d, %d) \n", r.x, r.y); return 0; } | cs |


https://itsys.hansung.ac.kr/cgi-bin/onlineTest/viewCcoding/onlineCcoding.cgi?source=src/chap11/struct_init.c
C프로그래밍(프로그래밍언어) 실습게시판