C++ 구조체 배열

Jmnote (토론 | 기여)님의 2023년 11월 26일 (일) 20:22 판 (새 문서: ==개요== ;C++ 구조체 배열 <syntaxhighlight lang='cpp' run> #include <iostream> using namespace std; typedef struct { int x; int y; } Point; int main() { Point p[...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

C++ 구조체 배열
#include <iostream>
using namespace std;

typedef struct {
    int x;
    int y;
} Point;

int main() {
    Point p[3] = {{1, 2}, {3, 4}, {5, 6}};
    cout << p[0].x << endl; // 1
    cout << p[0].y << endl; // 2
    cout << p[2].x << endl; // 5
    cout << p[2].y << endl; // 6
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}