Problem with passing 2-d array as a parameter to function. Please help

Hey @sahilkhan2312000131
Check this ,its method 1st, 2 & 3 : https://www.geeksforgeeks.org/pass-2d-array-parameter-c/
3rd is compatible with some compilers only so stick to 1st or 2nd

I have read this link. It doesn’t solve my problem. In this article, all examples have well defined 2-d arrays.
I want to know that if we have to make a 2-d array of size given as input by the user and pass it as a parameter. How should we pass it so that we do not get an error??

Hey @sahilkhan2312000131
I generally use vector nowdays so was having trouble .
You can use it like this : https://ide.codingblocks.com/s/350475

Hey @sahilkhan2312000131
If u know how to do dynamic allocation then you can do it like this as well :
https://ide.codingblocks.com/s/350477 :slight_smile:

Thank u Kartik. But I specifically want to know that is there any way that we can make a 2-d array of size given as input by the user and pass it as a parameter. Without making a Global Array.

We are doing that here ,by dynamic allocation

Also in its method 3 ,but not working with Coding blocks compiler .

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.