0Pricing
Zig Academy · 강의

*T를 사용하는 단일 항목 포인터

정확히 하나의 값을 가리킵니다.

*T를 사용하는 단일 항목 포인터은(는) CoddyKit의 무료 Zig Academy 강의입니다. 이것은 4개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Zig Academy 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Zig Academy 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

A Pointer Points

A pointer holds the address of a value living somewhere else in memory, instead of holding the value itself. 📍

The *T Type

A single-item pointer has the type *T, where T is what it points at. So *i32 means a pointer to one i32 value.

var p: *i32 = undefined;

Take an Address

Use the & operator in front of a variable to get a pointer to it. The result is the address where that value is stored.

var x: i32 = 10;
const p = &x;

One Value Only

A single-item pointer guarantees it refers to exactly one value, not an array. The compiler tracks that for you.

Pointers Have a Size

A pointer is just an address, so its size is the machine word, not the size of T. Pointing at a huge struct still costs one address.

Mutable by Default

A plain *T lets you both read and write the value it points to. You will add const later to make it read-only.

var n: i32 = 1;
const p: *i32 = &n;

Pointers Share, Not Copy

Passing a pointer to a function shares the original value, so changes made through it are visible to the caller.

fn bump(p: *i32) void {
    p.* += 1;
}

Address of a const

Taking &x on a const gives you a *const i32, because Zig will not let you write through a pointer to immutable data.

const x: i32 = 5;
const p = &x;

Pointers Are Never Null

An ordinary Zig pointer can never be null. If a value might be missing you must use an optional pointer like ?*T.

Type Inference Helps

When you write const p = &x, Zig infers the pointer type from x, so you rarely have to spell out *i32 by hand.

var score: u8 = 42;
const p = &score;

Why Use Pointers

Pointers let you modify a value in place and avoid copying large data, which is core to Zig's explicit low-level control.

Quick Check

You want a function to change a caller's variable. What type should the parameter be?

Recap

A single-item pointer *T holds the address of exactly one value, is taken with &, is never null, and lets you share data instead of copying it. 🎯

자주 묻는 질문

“*T를 사용하는 단일 항목 포인터” 강의는 무료인가요?

네 — “*T를 사용하는 단일 항목 포인터” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Zig Academy 강의 전체를 잠금 해제할 수 있습니다. Zig Academy 강의에는 총 4개의 강의가 포함되어 있습니다.

“*T를 사용하는 단일 항목 포인터”에서 뭘 배우나요?

정확히 하나의 값을 가리킵니다. 브라우저에서 직접 실행하는 실습 코드로 Zig Academy을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Zig Academy을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Zig Academy은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 1번째 강의입니다.

“*T를 사용하는 단일 항목 포인터” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Zig Academy 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Zig Academy 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. *T를 사용하는 단일 항목 포인터
  2. ptr.*로 역참조하기
  3. [*]T 다중 항목 포인터
  4. 상수 포인터와 정렬
← Zig Academy(으)로 돌아가기