[問題] address operator &

作者: zzss2003 (brotherD)   2018-04-22 17:18:59
網址:
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?
謝謝。
作者: stupid0319 (徵女友)   2018-04-22 18:48:00
我以為&不過就取記憶體位置,原來還有這麼多的研究
作者: firose (guest也是也是也是也是也)   2018-04-22 19:04:00
據他所說 &A 跟 &A[0] 是不一樣的型態,因為歷史因素有自動轉型為 pointer to array of int
作者: MOONRAKER (㊣牛鶴鰻毛人)   2018-04-23 14:53:00
不要看這篇。

Links booklink

Contact Us: admin [ a t ] ucptt.com