[問題] 關於二維陣列
看板C_and_CPP (C/C++)作者MaxHaru (懂得放手..才是王道)時間8年前 (2016/12/04 14:37)推噓10(10推 0噓 23→)留言33則, 7人參與討論串3/3 (看更多)
請教一個關於陣列的問題, 說明如下,
我有兩個二維陣列
unsigned char arr1[2][2] = {{1,2},{3,4}};
unsigned char arr2[2][2] = {{5,6},{7,8}};
我想用另一個陣列將兩個二陣列的位置存起來, 該如何宣告變數型態
unsigned char**pArr[2] = {arr1, arr2}; //不確定這樣宣告對不對..
我想再用一個變數將pArr中的二維陣列位址取出來並當二維陣列一樣使用
unsigned char**Var; //不確定是否正確
Var = pArr[0]; //不確定是否正確
printf("%d", Var[0][0]);
以上, 我有試著在Ideone上跑跑看( http://ideone.com/jUPUp9 )
compile沒有問題, 但執行時會出現誤會訊息..
請問是否哪個地方用錯了?
謝謝..
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.161.217.175
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1480833421.A.4D1.html
→
12/04 14:45, , 1F
12/04 14:45, 1F
推
12/04 14:58, , 2F
12/04 14:58, 2F
→
12/04 14:59, , 3F
12/04 14:59, 3F
推
12/04 15:02, , 4F
12/04 15:02, 4F
→
12/04 15:07, , 5F
12/04 15:07, 5F
→
12/04 15:08, , 6F
12/04 15:08, 6F
推
12/04 15:14, , 7F
12/04 15:14, 7F
推
12/04 15:15, , 8F
12/04 15:15, 8F
→
12/04 15:16, , 9F
12/04 15:16, 9F
推
12/04 15:18, , 10F
12/04 15:18, 10F
推
12/04 15:20, , 11F
12/04 15:20, 11F
→
12/04 15:20, , 12F
12/04 15:20, 12F
→
12/04 15:37, , 13F
12/04 15:37, 13F
→
12/04 15:38, , 14F
12/04 15:38, 14F
→
12/04 15:39, , 15F
12/04 15:39, 15F
推
12/04 16:06, , 16F
12/04 16:06, 16F
推
12/04 16:13, , 17F
12/04 16:13, 17F
→
12/04 16:13, , 18F
12/04 16:13, 18F
→
12/04 16:13, , 19F
12/04 16:13, 19F
→
12/04 16:16, , 20F
12/04 16:16, 20F
→
12/04 16:19, , 21F
12/04 16:19, 21F
推
12/04 16:30, , 22F
12/04 16:30, 22F
→
12/04 16:30, , 23F
12/04 16:30, 23F
→
12/04 16:30, , 24F
12/04 16:30, 24F
→
12/04 16:30, , 25F
12/04 16:30, 25F
→
12/04 16:30, , 26F
12/04 16:30, 26F
→
12/04 16:35, , 27F
12/04 16:35, 27F
→
12/04 16:41, , 28F
12/04 16:41, 28F
→
12/04 16:41, , 29F
12/04 16:41, 29F
→
12/04 16:45, , 30F
12/04 16:45, 30F
推
12/04 18:41, , 31F
12/04 18:41, 31F
→
12/04 19:00, , 32F
12/04 19:00, 32F
→
12/04 19:00, , 33F
12/04 19:00, 33F
討論串 (同標題文章)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章