--- id: c-arrays title: "C Arrays" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["array declaration", "fixed-size array", "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"] raw_sources: ["https://www.w3schools.com/c/c_arrays.php"] applied_in: [] github_commit: "" --- # [[C Arrays]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) Mixing types in an array literal (`int myArray[] = {25, 50, 75, 3.15, 5.99};`) doesn't always fail loudly β€” the source shows the float values `3.15`/`5.99` get silently TRUNCATED to `3`/`5` (since the array is typed `int`), and only "in some cases" does it produce an error, meaning the type-mismatch guard here is a silent-data-loss trap more often than a hard compile failure. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Array literal creation** β€” `type name[] = {val1, val2, ...};` creates and initializes an array in one step. [S1] - **Zero-based indexing** β€” `[0]` is the first element, `[1]` the second, and so on. [S1] - **Mutable elements** β€” any element can be reassigned by index after creation (`myNumbers[0] = 33;`). [S1] - **Size-first declaration** β€” `int myNumbers[4];` reserves space for 4 elements to be filled in later; the SIZE CANNOT CHANGE after creation. [S1] - **Same-type requirement** β€” all elements must share one data type; mismatched types get silently truncated/converted, not cleanly rejected. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Literal array creation and access: `int myNumbers[] = {25, 50, 75, 100}; printf("%d", myNumbers[0]); // 25`. [S1] - Modifying an element by index: `myNumbers[0] = 33; // Now outputs 33 instead of 25`. [S1] - Size-first, fill-later declaration: `int myNumbers[4]; myNumbers[0] = 25; myNumbers[1] = 50; myNumbers[2] = 75; myNumbers[3] = 100;`. [S1] - Type-mismatch truncation trap: `int myArray[] = {25, 50, 75, 3.15, 5.99};` β€” 3.15 and 5.99 silently become 3 and 5. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - **νƒ€μž…μ΄ μ„žμ΄λ©΄ 쑰용히 잘림**: int 배열에 float 값을 λ„£μœΌλ©΄ 항상 μ—λŸ¬κ°€ λ‚˜λŠ” 게 μ•„λ‹ˆλΌ λŒ€λΆ€λΆ„ μ†Œμˆ˜μ μ΄ μž˜λ €λ‚˜κ°€λŠ” ν˜•νƒœλ‘œ 쑰용히 처리되며, 일뢀 κ²½μš°μ—λ§Œ μ—λŸ¬κ°€ λ°œμƒν•œλ‹€λŠ” 점이 λͺ…μ‹œμ μœΌλ‘œ 경고됨. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” 크기λ₯Ό λ¨Όμ € μ„ μ–Έν•˜κ³  λ‚˜μ€‘μ— μš”μ†Œλ₯Ό μ±„μš°λŠ” 방식이 데이터가 순차적으둜 λ“€μ–΄μ˜¬ λ•Œ(예: μ‚¬μš©μž μž…λ ₯ 반볡) μ‹€μ „μ—μ„œ ν™œμš©λœλ‹€. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Declaring an array's size first, then filling in elements later (C): ```c int myNumbers[4]; myNumbers[0] = 25; myNumbers[1] = 50; myNumbers[2] = 75; myNumbers[3] = 100; ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.86 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[C Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[C Break Continue]], [[C Arrays Size]] - **μ°Έμ‘° λ§₯락:** λ°°μ—΄ μ„Ήμ…˜ 첫 챕터 β€” λ°°μ—΄ 크기(Arrays Size) μ±•ν„°λ‘œ 이어짐. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” C Arrays β€” https://www.w3schools.com/c/c_arrays.php ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "C Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).