--- id: cpp-strings title: "C++ Strings" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["string library include", "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: ["cpp", "programming-language", "w3schools", "strings"] raw_sources: ["https://www.w3schools.com/cpp/cpp_strings.asp"] applied_in: [] github_commit: "" --- # [[CPP Strings]] ## ๐ŸŽฏ ํ•œ ์ค„ ํ†ต์ฐฐ (One-line insight) Unlike C, where storing multi-word text requires manually managing a `char` array and worrying about the null terminator, C++'s `string` type stores spaces and punctuation transparently ("Hello and welcome!" works with zero special handling) โ€” proving that the earlier Data Types chapter's promise (string "behaves like" a built-in type) holds even for the exact scenario C explicitly warned about. [S1] ## ๐Ÿง  ํ•ต์‹ฌ ๊ฐœ๋… (Core concepts) - **`string`** โ€” stores a sequence of characters (text), double-quoted; requires `#include `. [S1] - **Multi-word support with zero friction** โ€” spaces and punctuation are stored and printed transparently, no escape handling or array sizing needed. [S1] ## ๐Ÿ“– ์„ธ๋ถ€ ๋‚ด์šฉ (Details) - Basic string with the required include: `#include string greeting = "Hello"; cout << greeting;`. [S1] - Multi-word string with spaces and punctuation: `string greeting = "Hello and welcome!"; cout << greeting;`. [S1] ## โš–๏ธ ๋ชจ์ˆœ ๋ฐ ์—…๋ฐ์ดํŠธ (Contradictions & updates) - **C์˜ ๋‹ค์ค‘ ๋‹จ์–ด ๋ฌธ์ž์—ด ๋ฌธ์ œ๊ฐ€ C++์—๋Š” ์—†์Œ**: C์—์„œ๋Š” char ๋ฐฐ์—ด์˜ ํฌ๊ธฐ์™€ ๋„ ์ข…๋ฃŒ ๋ฌธ์ž๋ฅผ ์‹ ๊ฒฝ ์จ์•ผ ํ–ˆ์ง€๋งŒ, C++ string์€ ๊ณต๋ฐฑ๊ณผ ๊ตฌ๋‘์ ์„ ํฌํ•จํ•œ ์—ฌ๋Ÿฌ ๋‹จ์–ด๋ฅผ ์•„๋ฌด ํŠน๋ณ„ ์ฒ˜๋ฆฌ ์—†์ด ๊ทธ๋Œ€๋กœ ์ €์žฅ/์ถœ๋ ฅํ•œ๋‹ค๋Š” ์ ์ด ํ™•์ธ๋จ. [S1] ## ๐Ÿ› ๏ธ ์ ์šฉ ์‚ฌ๋ก€ (Applied in summary) ํ˜„์žฌ ๋ฐœ๊ฒฌ๋œ ์‹ค์ œ ์ ์šฉ ์‚ฌ๋ก€๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค โ€” ํ—ค๋” ํฌํ•จ์ด ๋ฌธ์ž์—ด์„ ๋‹ค๋ฃจ๋Š” ๋ชจ๋“  C++ ํ”„๋กœ๊ทธ๋žจ์˜ ์‹ค์ „ ํ•„์ˆ˜ ์ „์ œ ์กฐ๊ฑด์ด๋‹ค. [S1] ## ๐Ÿ’ป ์ฝ”๋“œ ํŒจํ„ด (Code patterns) A multi-word string with spaces and punctuation, stored and printed transparently (C++): ```cpp #include string greeting = "Hello and welcome!"; cout << greeting; ``` ## โœ… ๊ฒ€์ฆ ์ƒํƒœ ๋ฐ ์‹ ๋ขฐ๋„ - **์ƒํƒœ:** draft - **๊ฒ€์ฆ ๋‹จ๊ณ„:** conceptual - **์ถœ์ฒ˜ ์‹ ๋ขฐ๋„:** B (W3Schools โ€” widely used educational reference, not a primary standards body) - **์‹ ๋ขฐ ์ ์ˆ˜:** 0.85 - **์ค‘๋ณต ๊ฒ€์‚ฌ ๊ฒฐ๊ณผ:** ์‹ ๊ทœ ์ƒ์„ฑ (New discovery) ## ๐Ÿ”— ์ง€์‹ ๊ทธ๋ž˜ํ”„ (Knowledge Graph) - **์ƒ์œ„/๋ฃจํŠธ:** [[C++ Tutorial]] - **๊ด€๋ จ ๊ฐœ๋…:** [[CPP Operators Precedence]], [[CPP Data Types String]], [[CPP Strings Access]] - **์ฐธ์กฐ ๋งฅ๋ฝ:** ๋ฌธ์ž์—ด ์„น์…˜ ์ฒซ ์ฑ•ํ„ฐ โ€” ๋ฌธ์ž์—ด ์ ‘๊ทผ(Strings Access) ์ฑ•ํ„ฐ๋กœ ์ด์–ด์ง. ## ๐Ÿ“š ์ถœ์ฒ˜ (Sources) - [S1] W3Schools โ€” C++ Strings โ€” https://www.w3schools.com/cpp/cpp_strings.asp ## ๐Ÿ“ ๋ณ€๊ฒฝ ์ด๋ ฅ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "C++ Strings" page (Astra wiki-curation, P-Reinforce v3.1 format).