2012年2月8日 星期三

C pointer


  • variable => one cell number 
  • type is used to inform the details about the variable
  • pointer is used to put an address

中文:
  • 任何變數都只是一段記憶體編號
  • 型別是用來說明此變數的資訊
  • 指標變數放的是記憶體位址
int *a; 
int **a;  ( 雙指標
int a[5];  ( a[0]的位址等於a
int *a[5]; ( array of 'pointer to int'
int (*a)[5]; ( pointer to array of int
int (*a)(); ( pointer to function

int (*(*a)())[5] ( 指標指向函式 其回傳一個指標指向5個元素的陣列

指標與陣列並不相等


關於函式指標
例子:用函式回傳一個指向陣列的指標



沒有留言:

張貼留言