--- id: c-variables title: "C Variables" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["variable declaration", "int float char", "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", "variables"] raw_sources: ["https://www.w3schools.com/c/c_variables.php"] applied_in: [] github_commit: "" --- # [[C Variables]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) Directly `printf()`-ing a variable like `printf(myNum)` is explicitly called out as an ERROR β€” unlike Python, Java, or C++ where a print function can accept a variable directly, C requires a separate "format specifier" placeholder mechanism to print any value, meaning the most natural instinct coming from another language (just print the variable) is a compile-breaking mistake in C. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Variable** β€” a named container for storing a data value; must have a specific TYPE that dictates what kind of data it can hold. [S1] - **Three introductory types** β€” `int` (whole numbers), `float` (decimal numbers), `char` (a single character in single quotes). [S1] - **Declaration syntax** β€” `type variableName = value;`, or declare first and assign later (`int myNum; myNum = 15;`). [S1] - **No direct variable printing** β€” `printf(myNum)` is invalid; C requires format specifiers (covered in the next chapter) to print variable values. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Declare-and-assign in one line: `int myNum = 15;`. [S1] - Declare first, assign later: `int myNum; myNum = 15;`. [S1] - The explicit error case: `int myNum = 15; printf(myNum); // This will cause an error`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - **λ‹€λ₯Έ μ–Έμ–΄μ™€μ˜ 좜λ ₯ 방식 차이**: Python/Java/C++와 달리 Cμ—μ„œλŠ” printf()에 λ³€μˆ˜λ₯Ό 직접 λ„£μ–΄ 좜λ ₯ν•  수 μ—†κ³  λ°˜λ“œμ‹œ 포맷 μ§€μ •μžλ₯Ό μ‚¬μš©ν•΄μ•Ό ν•œλ‹€λŠ” 점이 λͺ…μ‹œμ μœΌλ‘œ 경고됨. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” λ³€μˆ˜λ₯Ό λ¨Όμ € μ„ μ–Έλ§Œ ν•˜κ³  λ‚˜μ€‘μ— 값을 λŒ€μž…ν•˜λŠ” νŒ¨ν„΄μ΄ 쑰건에 따라 값이 κ²°μ •λ˜λŠ” μ‹€μ „ λ‘œμ§μ—μ„œ ν”νžˆ 쓰인닀. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Declaring a variable first, then assigning its value later (C): ```c // Declare a variable int myNum; // Assign a value later myNum = 15; ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.86 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[C Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[C Organize Code]], [[C Variables Names]], [[C Variables Format]] - **μ°Έμ‘° λ§₯락:** λ³€μˆ˜ μ„Ήμ…˜ 첫 챕터 β€” λ³€μˆ˜ 이름 κ·œμΉ™(Variables Names) μ±•ν„°λ‘œ 이어짐. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” C Variables β€” https://www.w3schools.com/c/c_variables.php ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "C Variables" page (Astra wiki-curation, P-Reinforce v3.1 format).