0

Multidimensional array as an argument of a function C++

How can I pass a multidimensional array as a function's argument in C++ which will be inputted by the user

26th Sep 2019, 7:40 PM
ikram bakkali
ikram bakkali - avatar
2 Respuestas
+ 1
Let's say you have the function getInput() for your input. Having a two-dimensional array int names[10][10], you could declare getInput as "void getInput(int **array,int rows, int cols)" since the name of the 2D array will be a pointer pointing on a pointer. Then call getInput with getInput(names,10,10). I'm using rows and cols on parameters to know your borders. Following the same pattern for a 3D array it should be getInput(int ***array,int x,int y,int z).
26th Sep 2019, 10:22 PM
Thanos A.
Thanos A. - avatar