To pass a 2D array with user-defined size to a function in C/C++, you can’t use fixed-size arrays.
Instead, you must use pointers, dynamic memory, or variable-length arrays (VLA) (C only).
Below are the correct and clean methods.
Method 1: Using Variable-Length Arrays (C Only — Simple & Recommended)
Method 2: Using Pointer-to-Pointer (Works in C and C++)
Method 3: Passing a Single Pointer (Flattened 2D Array)