--- id: c-arrays-multi title: "C Multidimensional Arrays" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["2D array", "matrix", "3D array", "C 다차원 배열"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.85 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["c", "programming-language", "w3schools", "arrays", "multidimensional"] raw_sources: ["https://www.w3schools.com/c/c_arrays_multi.php"] applied_in: [] github_commit: "" --- # [[C Multidimensional Arrays]] ## 🎯 한 줄 통찰 (One-line insight) A multidimensional array is defined as literally "an array of arrays," and this compounds directly into the looping requirement: an N-dimensional array needs exactly N nested loops to visit every element — a 2D array needs 2 nested loops (as shown), a 3D array would need 3 — meaning the loop-nesting depth isn't a stylistic choice but a direct structural consequence of how many dimensions the array has. [S1] ## 🧠 핵심 개념 (Core concepts) - **Multidimensional array** — "basically an array of arrays"; C supports any number of dimensions, with 2D being the most common. [S1] - **2D array (`type name[rows][cols]`)** — a matrix/table; first bracket = row count, second bracket = column count. [S1] - **Dual-index access** — `matrix[row][col]` addresses a specific cell; both indices are zero-based. [S1] - **One nested loop per dimension** — looping a 2D array fully requires 2 nested loops (outer for rows, inner for columns); a 3D array would require 3 nested loops. [S1] - **3D arrays (`type name[blocks][rows][cols]`)** — represent structures like multiple tables or game levels, each block itself being a 2D array. [S1] ## 📖 세부 내용 (Details) - Creating and accessing a 2D array: `int matrix[2][3] = { {1, 4, 2}, {3, 6, 8} }; printf("%d", matrix[0][2]); // Outputs 2`. [S1] - Modifying a specific cell: `matrix[0][0] = 9; // Now outputs 9 instead of 1`. [S1] - Fully looping a 2D array with nested loops: `for (i = 0; i < 2; i++) { for (j = 0; j < 3; j++) { printf("%d\n", matrix[i][j]); } }`. [S1] - Declaring a 3D array (2 blocks × 4 rows × 3 columns): `int example[2][4][3];`. [S1] ## ⚖️ 모순 및 업데이트 (Contradictions & updates) - **차원 수와 중첩 루프 개수의 직접 대응**: 2차원 배열은 중첩 루프 2개, 3차원 배열은 중첩 루프 3개가 필요하다는 구조적 대응 관계가 명시적으로 확인됨. [S1] ## 🛠️ 적용 사례 (Applied in summary) 2D 배열은 점수표, 게임판, 스프레드시트에, 3D 배열은 여러 테이블의 집합이나 게임의 여러 레벨 같은 복잡한 구조 표현에 적합하다고 원문에서 직접 제시됨. [S1] ## 💻 코드 패턴 (Code patterns) Fully iterating a 2D array requires one nested loop per dimension (C): ```c int matrix[2][3] = { {1, 4, 2}, {3, 6, 8} }; int i, j; for (i = 0; i < 2; i++) { for (j = 0; j < 3; j++) { printf("%d\n", matrix[i][j]); } } ``` ## ✅ 검증 상태 및 신뢰도 - **상태:** draft - **검증 단계:** conceptual - **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body) - **신뢰 점수:** 0.85 - **중복 검사 결과:** 신규 생성 (New discovery) ## 🔗 지식 그래프 (Knowledge Graph) - **상위/루트:** [[C Tutorial]] - **관련 개념:** [[C Arrays Loop]], [[C For Loop Nested]], [[C Arrays RealLife]] - **참조 맥락:** 다차원 배열 — 배열 실전 예제(Arrays RealLife) 챕터로 이어짐. ## 📚 출처 (Sources) - [S1] W3Schools — C Multidimensional Arrays — https://www.w3schools.com/c/c_arrays_multi.php ## 📝 변경 이력 (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "C Multidimensional Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).