Re: [問題] 陣列和指標的問題
※ 引述《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
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):