--- id: c-pointers title: "C Pointers" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["pointer declaration", "dereference operator", "C 포인터"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.87 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["c", "programming-language", "w3schools", "pointers"] raw_sources: ["https://www.w3schools.com/c/c_pointers.php"] applied_in: [] github_commit: "" --- # [[C Pointers]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) The `*` symbol does two OPPOSITE jobs depending on where it appears β€” in a declaration (`int* ptr`) it CREATES a pointer, but everywhere else (`*ptr`) it DEREFERENCES one to retrieve the pointed-to value β€” and the source explicitly flags this dual meaning as a common source of confusion, since the same character means "this variable will hold an address" in one context and "give me what's at this address" in another. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Pointer** β€” a variable that stores another variable's memory address as its value. [S1] - **Type-matched declaration** β€” a pointer's declared type must match the type of variable it points to (`int* ptr` for an `int`). [S1] - **`*` in declaration vs. elsewhere** β€” `int* ptr;` creates a pointer variable; `*ptr` (outside declaration) dereferences it to get the pointed-to value. [S1] - **Two equivalent declaration styles** β€” `int* myNum;` and `int *myNum;` are functionally identical; spacing around `*` is purely stylistic. [S1] - **Why pointers matter** β€” enable direct memory manipulation (reducing code, improving performance), are essential for implementing data structures (lists, trees, graphs), and are sometimes REQUIRED (e.g. file I/O, memory management). [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Creating a pointer and reading the address it stores: `int myAge = 43; int* ptr = &myAge; printf("%p\n", ptr); // same address as &myAge`. [S1] - Dereferencing to get the pointed-to value: `printf("%d\n", *ptr); // 43 (myAge's value, accessed via the pointer)`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - **`*`의 이쀑 의미**: μ„ μ–Έμ—μ„œ 쓰인 int* ptrλŠ” 포인터 λ³€μˆ˜λ₯Ό λ§Œλ“€μ§€λ§Œ, 선언이 μ•„λ‹Œ κ³³μ—μ„œ 쓰인 *ptrλŠ” μ—­μ°Έμ‘° μ—°μ‚°μžλ‘œ λ™μž‘ν•œλ‹€λŠ” 점이 ν˜Όλ™ μš”μ†Œλ‘œ λͺ…μ‹œμ μœΌλ‘œ 지적됨. [S1] - **포인터 μ·¨κΈ‰ μ‹œ μ£Όμ˜μ‚¬ν•­**: λ‹€λ₯Έ λ©”λͺ¨λ¦¬ μ£Όμ†Œμ— μ €μž₯된 데이터λ₯Ό μ†μƒμ‹œν‚¬ 수 μžˆμœΌλ―€λ‘œ ν¬μΈν„°λŠ” μ‹ μ€‘ν•˜κ²Œ 닀뀄야 ν•œλ‹€κ³  경고됨. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” 리슀트/트리/κ·Έλž˜ν”„ 같은 자료ꡬ쑰λ₯Ό κ΅¬ν˜„ν•˜κ±°λ‚˜ 파일 및 λ©”λͺ¨λ¦¬ 관리 μž‘μ—…μ„ ν•  λ•Œ 포인터가 ν•„μˆ˜μ μœΌλ‘œ 쓰인닀고 μ›λ¬Έμ—μ„œ 직접 언급됨. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Creating a pointer, then reading the address vs. the dereferenced value (C): ```c int myAge = 43; // Variable declaration int* ptr = &myAge; // Pointer declaration printf("%p\n", ptr); // Reference: memory address of myAge printf("%d\n", *ptr); // Dereference: value of myAge (43) ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.87 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[C Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[C Memory Address]], [[C Pointers Arithmetic]] - **μ°Έμ‘° λ§₯락:** 포인터 기초 β€” 포인터 μ—°μ‚°(Pointers Arithmetic) μ±•ν„°λ‘œ 이어짐. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” C Pointers β€” https://www.w3schools.com/c/c_pointers.php ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "C Pointers" page (Astra wiki-curation, P-Reinforce v3.1 format).