作者zzss2003 (brotherD)
看板C_and_CPP
標題[問題] address operator &
時間Sun Apr 22 17:18:59 2018
網址:
https://stackoverflow.com/questions/49890211/address-operator-and-array-in-assembly-level
在Answer裡面提到:
The address of & operator allows you to construct a pointer to value from a
variable of same type as value.
中文翻譯:address operator允許你建構一個指標(from一個變數to value,且這個變數有
跟value一樣的type)
請問,這一行的意思是不是指,當執行程式這一行時:
p = &var1;
&本身也會占用一個variable的空間(用來放var1的address),然後在把這個address給p?
接下來,內文提到:
int *p = &A;
程式在做這行指令時,you are doing an assignment from a pointer to array of int
into a variable of type array of int, which is a different type.
光看這行英文,哪有different type,一樣是array of int啊
還是他打錯了?應該是from a pointer to int into a variable of type array of int?
謝謝。
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.248.26.157
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1524388743.A.75B.html
→ stupid0319: 我以為&不過就取記憶體位置,原來還有這麼多的研究 04/22 18:48
→ firose: 據他所說 &A 跟 &A[0] 是不一樣的型態,因為歷史因素有自 04/22 19:04
→ firose: 動轉型為 pointer to array of int 04/22 19:05
→ MOONRAKER: 不要看這篇。 04/23 14:53