[問題] 函數傳入值
有問題的code: (請善用置底文標色功能)
int cur(int *b)
{
int tmp;
tmp = b[0][0];
return tmp;
}
int main()
{
int b[10][10];
int c;
c = cur(b);
return 0;
}
我想要在 cur 函數中使用main 裡面的二維陣列
不知道要怎麼寫才能夠 順利讀入
明明一維陣列 就可以
程式跑出來的錯誤結果:
In function `int cur(int*)':
invalid types `int[int]' for array subscript
In function `int main()':
cannot convert `int (*)[10]' to `int*' for argument `1' to `int cur(int*)'
[Build Error] [1.o] Error 1
開發平台: (例: VC++ or gcc/g++ or Dev-C++, Windows or Linux)
Dev-C++
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.250.9.82
→
08/18 08:53, , 1F
08/18 08:53, 1F
→
08/18 09:03, , 2F
08/18 09:03, 2F
→
08/18 09:04, , 3F
08/18 09:04, 3F
→
08/18 09:09, , 4F
08/18 09:09, 4F
→
08/18 09:12, , 5F
08/18 09:12, 5F
推
08/18 09:15, , 6F
08/18 09:15, 6F
→
08/18 09:21, , 7F
08/18 09:21, 7F
→
08/18 09:22, , 8F
08/18 09:22, 8F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章