--- id: c-booleans title: "C Booleans" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["bool type", "stdbool.h", "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", "booleans", "stdbool"] raw_sources: ["https://www.w3schools.com/c/c_booleans.php"] applied_in: [] github_commit: "" --- # [[C Booleans]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) `bool` is NOT a built-in C type like `int` or `char` β€” it was only added in C99 and requires explicitly including ``, meaning code written for older/stricter C standards, or code that forgets this include, has no `bool` keyword at all and must fall back to plain `int` with 1/0 conventions instead. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`bool`** (C99+, via ``) β€” a type representing exactly two values: `true` or `false`. [S1] - **Underlying integer representation** β€” booleans print as integers: `1` (or any non-zero) for true, `0` for false, using the `%d` specifier. [S1] - **Bool-to-bool comparison** β€” bool variables can be compared with `==` just like any other value (e.g. checking if two bools are both true). [S1] - **Storing comparison results** β€” a comparison's result (already a 1/0 value) can be stored directly in a `bool` variable for readability and reuse. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Declaring and printing bools: `bool isProgrammingFun = true; bool isFishTasty = false; printf("%d", isProgrammingFun); // 1 printf("%d", isFishTasty); // 0`. [S1] - Comparing two bool variables: `bool isHamburgerTasty = true; bool isPizzaTasty = true; printf("%d", isHamburgerTasty == isPizzaTasty); // 1`. [S1] - Storing a comparison result in a bool: `int x = 10; int y = 9; bool isGreater = x > y; printf("%d", isGreater); // 1`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - **bool은 C의 λ‚΄μž₯ νƒ€μž…μ΄ μ•„λ‹˜**: intλ‚˜ char와 달리 bool은 C99μ—μ„œ λ„μž…λ˜μ—ˆκ³  λ°˜λ“œμ‹œ λ₯Ό 포함해야 μ‚¬μš© κ°€λŠ₯ν•˜λ‹€λŠ” 점이 λͺ…μ‹œμ μœΌλ‘œ 강쑰됨. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” 비ꡐ κ²°κ³Όλ₯Ό bool λ³€μˆ˜μ— μ €μž₯ν•΄ μž¬μ‚¬μš©ν•˜λŠ” 것이 μ½”λ“œ 가독성을 λ†’μ΄λŠ” μ‹€μ „ μŠ΅κ΄€μœΌλ‘œ ꢌμž₯λœλ‹€. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Storing a comparison's result in a bool variable for readability (C): ```c #include int x = 10; int y = 9; bool isGreater = x > y; printf("%d", isGreater); // Prints 1 (true) ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.86 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[C Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[C Random Numbers]], [[C Operators Comparison]], [[C Booleans RealLife]] - **μ°Έμ‘° λ§₯락:** λΆˆλ¦¬μ–Έ μ„Ήμ…˜ 첫 챕터 β€” λΆˆλ¦¬μ–Έ μ‹€μ „ 예제(Booleans RealLife) μ±•ν„°λ‘œ 이어짐. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” C Booleans β€” https://www.w3schools.com/c/c_booleans.php ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "C Booleans" page (Astra wiki-curation, P-Reinforce v3.1 format).