作者sumty (elva)
看板b96902HW
标题[钢弹] 6-2 二维阵列跟函式的问题
时间Sat Nov 10 13:37:49 2007
/*6-2*/
void con(int*,int,int);
int main(){
int row,col,im[size][size];
......
con(im,row,col); /*第15行*/
........
}
void con(int*im,int row,int col){
if(.....){
if(im[row][col]==1){ /*第24行*/
...............
}
}
}
出现这样的compiler waring跟error (p.s.在linux操作环境下)
b96025@linux8 [~/hw/a6] gcc a6-p2.c
a6-p2.c: In function 'main':
a6-p2.c:15: warning: passing argument 1 of 'con' from incompatible pointer
type
a6-p2.c: In function 'con':
a6-p2.c:24: error: subscripted value is neither array nor pointer
想请问大家,这是什麽意思呢?
是否是二维阵列不能以指标的方式丢到函式里
如果是
想请教大家我要如何能将二维阵列放进函式里处理
感激不尽
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 122.120.3.198
1F:推 simonxander:这我也不知道甚麽意思XD 不过有两种方法可以解决 11/10 18:04
2F:→ simonxander:1 不要用函式就好啦~ 11/10 18:05
3F:→ simonxander:2 void con(int im[size][size]) 11/10 18:06
4F:→ simonxander:main 里传入 con(im) 11/10 18:07
5F:→ simonxander:这样是传址喔~ 喔 还有第三种 直接开全域变数 11/10 18:07
6F:→ simonxander:就不用传了... 11/10 18:08
7F:推 Himax:果然还是只好用全域变数大绝招了 11/10 21:18
8F:推 ec75413:con(int **im) 想挑战者 请使用指标的指标 11/10 22:17