Re: [問題] 怎樣把二維陣列傳給另一個function

看板C_and_CPP (C/C++)作者 (audi)時間16年前 (2009/04/05 02:04), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串6/6 (看更多)
※ 引述《y2jj (.)》之銘言: : #include <stdio.h> : #include <stdlib.h> : int x,y; : void sub(int b[x][y]){ : … : } : void main(){ : printf("x:");scanf("%d",&x); : printf("y:");scanf("%d",&y); : int a[x][y]; : sub(a); : } : 錯誤訊息:variable-size type declared outside of any function : 我想讓副程式sub知道陣列維度 : 不知道錯在哪邊 : 請各位前輩指點 謝謝~~~ void sub(int b[x][y]) =>錯 編譯時期compiler不知道你的陣列維度(你不能用變數做宣告陣列維度), 只能用常數 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.47.163.130
文章代碼(AID): #19rw4P6C (C_and_CPP)
文章代碼(AID): #19rw4P6C (C_and_CPP)