> 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/pointer/function-pointer.md).

# function pointer

宣告函式時同樣需要一些記憶體 addr 來存, 簡單來說, 用存取指標來call function

**用途 :**

可以把function call 當引數傳遞

**宣告: (記法 - 把 function name 換成 記憶體位址)**

func\_return\_type (\*pointer\_name)(arguments);

**函式指標陣列 :**

function\_return\_type (\*pointer\_name\[array\_length])(argument);

**ex: (interview-c/pointer/func\_ptr/sort/enhance)**

`int (*compare[10])(int, int); //可以儲存十個sort function的位址`

**比較好的寫法 - typedef**

`typedef int (*CMP)(int, int);`

`CMP compare[10];`
