[問題] address operator &

看板C_and_CPP作者 (brotherD)時間7年前 (2018/04/22 09:19), 編輯推噓0(004)
留言4則, 3人參與, 7年前最新討論串1/2 (看更多)
網址: 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

04/22 18:48, 7年前 , 1F
我以為&不過就取記憶體位置,原來還有這麼多的研究
04/22 18:48, 1F

04/22 19:04, 7年前 , 2F
據他所說 &A 跟 &A[0] 是不一樣的型態,因為歷史因素有自
04/22 19:04, 2F

04/22 19:05, 7年前 , 3F
動轉型為 pointer to array of int
04/22 19:05, 3F

04/23 14:53, 7年前 , 4F
不要看這篇。
04/23 14:53, 4F
文章代碼(AID): #1Qt5E7TR (C_and_CPP)
討論串 (同標題文章)
文章代碼(AID): #1Qt5E7TR (C_and_CPP)