--- id: c-constants title: "C Constants" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["const keyword", "read-only variables", "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", "constants"] raw_sources: ["https://www.w3schools.com/c/c_constants.php"] applied_in: [] github_commit: "" --- # [[C Constants]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) A `const` variable MUST be assigned a value at the moment of declaration β€” declaring it first and assigning later (`const int minutesPerHour; minutesPerHour = 60;`) is explicitly shown as an error β€” meaning `const` isn't just "can't change later," it also removes the two-step declare-then-assign pattern that ordinary variables freely support. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`const` keyword** β€” makes a variable unchangeable/read-only after its initial assignment. [S1] - **Mandatory initialization** β€” a `const` variable must receive its value at declaration time; assigning it afterward is a compile error. [S1] - **Uppercase naming convention** β€” while not required, C programmers commonly write constant names in uppercase (e.g. `BIRTHYEAR`) for readability. [S1] - **Use case** β€” values unlikely to ever change during program execution (e.g. `minutesPerHour`, `monthsInYear`). [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Attempting reassignment fails: `const int myNum = 15; myNum = 10; // error: assignment of read-only variable 'myNum'`. [S1] - Declare-without-assign fails: `const int minutesPerHour; minutesPerHour = 60; // error`. [S1] - Uppercase convention: `const int BIRTHYEAR = 1980;`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - **constλŠ” μ„ μ–Έκ³Ό λ™μ‹œμ— μ΄ˆκΈ°ν™” ν•„μˆ˜**: 일반 λ³€μˆ˜μ²˜λŸΌ λ¨Όμ € μ„ μ–Έλ§Œ ν•˜κ³  λ‚˜μ€‘μ— 값을 λŒ€μž…ν•˜λŠ” 방식이 constμ—μ„œλŠ” 컴파일 μ—λŸ¬λ₯Ό λ°œμƒμ‹œν‚¨λ‹€λŠ” 점이 λͺ…μ‹œμ μœΌλ‘œ 확인됨. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” μ‹œκ°„λ‹Ή λΆ„(60), 연쀑 κ°œμ›” 수(12)처럼 μ ˆλŒ€ λ³€ν•˜μ§€ μ•ŠλŠ” 값을 const둜 μ„ μ–Έν•˜λŠ” 것이 μ‹€μ „ μ½”λ“œμ—μ„œμ˜ ν‘œμ€€ ν™œμš©μ΄λ‹€. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Declaring constants that must be initialized at the point of declaration (C): ```c const int minutesPerHour = 60; const int monthsInYear = 12; const int BIRTHYEAR = 1980; // uppercase is a common naming convention ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.85 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[C Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[C Data Types RealLife]], [[C Storage Classes]] - **μ°Έμ‘° λ§₯락:** μƒμˆ˜ μ„ μ–Έ β€” μ €μž₯ 클래슀(Storage Classes) μ±•ν„°λ‘œ 이어짐. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” C Constants β€” https://www.w3schools.com/c/c_constants.php ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "C Constants" page (Astra wiki-curation, P-Reinforce v3.1 format).