docs(10_Wiki): Dev 폴더 누락분 반영 — Topic_Programming으로 통합
이전 재구성 작업에서 Dev/ 폴더가 누락되었던 것을 반영. - Dev/Topic_Programming(중첩 폴더, 78개)은 Dev 자체 최상위 폴더들 (Architecture/Conventions/Engineering_Intelligence 등)과 완전 중복이라 제거. - Dev 최상위 엔지니어링 지식 폴더(Architecture/Conventions/Engineering_Intelligence/ Failure_Library/Generalized_Principles/Language/Pattern_Catalog/Platform_Guides/ Subsystems, 77개)는 이미 Topic_Programming/Topic_Programming에 더 최신 버전이 존재해 중복 제거(고유 콘텐츠 1개는 예외 처리하여 이동 보존). - Dev의 W3Schools 언어 튜토리얼 폴더(Topic_C/CPP/CSS/CSharp/HOWTO/HTML/Java/ JavaScript/PHP/Python/SQL/W3CSS, 1201개)는 전부 Topic_Programming 하위로 이동. - 에이전트 운영 상태(.astra/docs)는 그대로 유지, 콘텐츠 폴더만 정리. - Topic_Programming 최종 문서 수: 2784 → 3985.
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: c-arrays-loop
|
||||
title: "C Array Loop"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["loop through array", "adaptive loop length", "C 배열 반복문"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.86
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["c", "programming-language", "w3schools", "arrays", "loops"]
|
||||
raw_sources: ["https://www.w3schools.com/c/c_arrays_loop.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[C Array Loop]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
A hardcoded loop bound (`i < 4`) silently breaks the moment the array's contents change size — the source explicitly flags this as "not ideal, since it will only work for arrays of a specified size" — while replacing it with `sizeof(arr)/sizeof(arr[0])` makes the SAME loop automatically correct for an array of ANY length, turning a brittle magic number into a self-maintaining computation. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Hardcoded loop bound (fragile)** — `for (i = 0; i < 4; i++)` only works correctly for exactly a 4-element array; adding/removing elements breaks it silently. [S1]
|
||||
- **`sizeof` formula-driven bound (robust)** — `int length = sizeof(arr) / sizeof(arr[0]); for (i = 0; i < length; i++)` automatically adapts to the array's actual current size. [S1]
|
||||
- **Standing rule** — the chapter's own summary: "Always use the sizeof formula when looping through arrays." [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Fragile hardcoded-bound loop: `int myNumbers[] = {25, 50, 75, 100}; int i; for (i = 0; i < 4; i++) { printf("%d\n", myNumbers[i]); }`. [S1]
|
||||
- Robust size-adaptive loop: `int myNumbers[] = {25, 50, 75, 100}; int length = sizeof(myNumbers) / sizeof(myNumbers[0]); int i; for (i = 0; i < length; i++) { printf("%d\n", myNumbers[i]); }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **하드코딩된 루프 경계의 취약성**: 배열 원소 개수가 바뀌면 i < 4 같은 고정된 조건이 더 이상 맞지 않게 된다는 점이 "이상적이지 않다"고 명시적으로 지적되며, sizeof 공식을 항상 쓰라는 규칙으로 이어짐. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — sizeof 기반 반복문이 이후 Arrays RealLife 챕터의 평균 계산·최솟값 찾기 예제에서 그대로 재사용된다. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
A loop that automatically adapts to any array size using the sizeof formula (C):
|
||||
```c
|
||||
int myNumbers[] = {25, 50, 75, 100};
|
||||
int length = sizeof(myNumbers) / sizeof(myNumbers[0]);
|
||||
int i;
|
||||
for (i = 0; i < length; i++) {
|
||||
printf("%d\n", myNumbers[i]);
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C Tutorial]]
|
||||
- **관련 개념:** [[C Arrays Size]], [[C Arrays Multi]], [[C Arrays RealLife]]
|
||||
- **참조 맥락:** 배열 반복문 — 다차원 배열(Arrays Multi) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C Array Loop — https://www.w3schools.com/c/c_arrays_loop.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C Array Loop" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user