作者sbrhsieh (sbr)
看板C_and_CPP
標題Re: [問題] 陣列和指標的問題
時間Fri May 8 00:02:48 2009
※ 引述《heathlow ()》之銘言:
: int (*match_buf)[2] = new int[m_iNum1][2];
: 上面這一行程式,
: 我在VC中編譯可以過.
: 如果拿掉等號左側的括號變成
: int* match_buf[2] = new int[m_iNum1][2];
: 就會出錯.
: 我想請問一下原因是甚麼?
前者 match_buf 是一個 pointer, point to array(int[2])。
後者 match_buf 是一個 length 為 2 的 pointer array。(match_buf[0],
match_buf[1] 的 type 是 int*)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.173.130.231