Please see this
] and this
] question from comp.lang.c
The answers to these two questions contain all you need. :)
BTW: Your question is tagged as C++ not C. Above links will solve the problem in your C - style code.
If you want to change your code to C++ - style, then you can replace your two dimensional integer array with
std::vector< std::vector<int> >
]) and pass this vector by reference to your function. :)