0

passing a 2D array to a function

how do i pass a 2d array to a function in this code: int main(){ int x,y; cin >> x; cin >> y; int grid[y][x]; myFunc(grid); }

13th Jun 2019, 7:08 AM
Cat Sauce
Cat Sauce - avatar
2 Answers
+ 2
Exactly as you did- myFunc(grid); The problem is that you cant declare an array with a non-fixed length, you need to use "new" for that
13th Jun 2019, 9:24 PM
daniel
daniel - avatar
+ 1
daniel what do you mean?
13th Jun 2019, 10:59 PM
Cat Sauce
Cat Sauce - avatar