> For the complete documentation index, see [llms.txt](https://fashaun.gitbook.io/dev-c/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fashaun.gitbook.io/dev-c/struct-1/struct-and-pointer.md).

# Struct and Pointer

**宣告 struct 指標**

1. 實例化一個 struct
2. 實例化一個 struct 類型的指標
3. 用指標指到該 struct 的記憶體位址

**存取struct 指標**

`->`

**存取struct instance 位址**

`&struct`

**struct 引數傳遞位址**

使用時機

想改變直接修改傳遞實例內容

struct 內容龐大 , 不想複製整個實例

**存取實例成員 color 位址**

`struct Ball ball {"blue", "8.0"};`

`printf("%p", &(ball.color))`

**同理, 若**

struct Ball \*ptr;

\*ptr = \&ball;

`printf("%p", &(ptr->color))`
