--- id: c-pointers-arrays title: "C Pointers and Arrays" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["array name as pointer", "array-pointer equivalence", "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", "arrays"] raw_sources: ["https://www.w3schools.com/c/c_pointers_arrays.php"] applied_in: [] github_commit: "" --- # [[C Pointers and Arrays]] ## 🎯 한 줄 통찰 (One-line insight) An array's NAME already IS a pointer to its first element — proven directly by printing `myNumbers` and `&myNumbers[0]` and getting the IDENTICAL address — meaning `*myNumbers` (dereferencing the bare array name) works exactly like `myNumbers[0]`, and the entire array-indexing syntax `arr[i]` is really syntactic sugar over pointer arithmetic (`*(arr + i)`) that's been running underneath the whole time. [S1] ## 🧠 핵심 개념 (Core concepts) - **Array name = pointer to first element** — `myNumbers` and `&myNumbers[0]` evaluate to the exact same address. [S1] - **`*arrayName`** — dereferences the array's implicit pointer to get the FIRST element's value, equivalent to `arrayName[0]`. [S1] - **`*(arrayName + i)`** — equivalent to `arrayName[i]`; offsetting the array-as-pointer by `i` and dereferencing reaches the same element as bracket indexing. [S1] - **Mutation via dereference** — `*myNumbers = 13;` changes the first element just like `myNumbers[0] = 13;` would. [S1] - **Element memory layout confirms the size math** — consecutive `int` elements' addresses differ by exactly `sizeof(int)` (4 bytes), so an array of 4 ints occupies 16 bytes total. [S1] ## 📖 세부 내용 (Details) - Proving array-name-equals-pointer: `printf("%p\n", myNumbers); printf("%p\n", &myNumbers[0]); // identical addresses`. [S1] - Dereferencing the bare array name for the first element: `printf("%d", *myNumbers); // 25 (same as myNumbers[0])`. [S1] - Offsetting to reach later elements: `printf("%d\n", *(myNumbers + 1)); // 50 printf("%d", *(myNumbers + 2)); // 75`. [S1] - Mutating through dereference: `*myNumbers = 13; *(myNumbers + 1) = 17;` changes the first and second elements. [S1] ## ⚖️ 모순 및 업데이트 (Contradictions & updates) - **배열 이름은 이미 포인터**: 배열 이름을 그대로 출력한 주소와 &배열[0]으로 얻은 주소가 완전히 동일하다는 점이 직접 증명되며, 이는 배열 인덱싱(arr[i])이 실제로는 포인터 연산(*(arr+i))의 편의 문법임을 시사함. [S1] ## 🛠️ 적용 사례 (Applied in summary) 대용량 배열이나 2차원 배열, 그리고 배열인 문자열(string)에 접근할 때 포인터 방식이 더 효율적이고 빠르다는 점이 원문에서 직접 언급됨. [S1] ## 💻 코드 패턴 (Code patterns) An array's name and the address of its first element are identical (C): ```c int myNumbers[4] = {25, 50, 75, 100}; printf("%p\n", myNumbers); // e.g. 0x7ffe70f9d8f0 printf("%p\n", &myNumbers[0]); // same address: 0x7ffe70f9d8f0 printf("%d", *myNumbers); // 25, same as myNumbers[0] ``` ## ✅ 검증 상태 및 신뢰도 - **상태:** draft - **검증 단계:** conceptual - **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body) - **신뢰 점수:** 0.87 - **중복 검사 결과:** 신규 생성 (New discovery) ## 🔗 지식 그래프 (Knowledge Graph) - **상위/루트:** [[C Tutorial]] - **관련 개념:** [[C Pointers Arithmetic]], [[C Pointer To Pointer]], [[C Arrays Multi]] - **참조 맥락:** 포인터와 배열의 관계 — 포인터의 포인터(Pointer To Pointer) 챕터로 이어짐. ## 📚 출처 (Sources) - [S1] W3Schools — C Pointers and Arrays — https://www.w3schools.com/c/c_pointers_arrays.php ## 📝 변경 이력 (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "C Pointers and Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).