We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Has anyone found a way to pass 2 dimentional arrays to a function? My arrays are stored in code and I need to pass them to a function to display them. Gary Martin
Without testing, the code below should work: // Data int array2d[5][5]; // Function Prototype void func(int ** pArray2d); // Main function void main(void) { func(array2d); } void func(int ** pArray2d) { pArray2d[0][0] = 3; pArray2d[0][1] = 4; // etc... }
Yes it should, but it dosen't. Gary Martin
Yes, Without testing, it works. But when tested it doesn't.
void func(int ** pArray2d)
unsigned char _2d_array [5][5]; void func (unsigned char (*x)[5]) { x [0][0] = 1; x [1][0] = 6; x [2][1] = 12; } void main (void) { func (_2d_array); while (1); }
void func (unsigned char (*x)[5])
Whoops, you are quite right.