Out of curiosity, I change the line to set_array(&array1[0]) in the following from set_array[array1], the parameter is not the same type, but it works, any idea?
#include <stdio.h>
void set_array(int array[][9]);
int main(void) {
int array1[4][9];
for(int i = 0; i < 4; i++) {
for(int j = 0; j < 9; j++) {
array1[i][j] = j + 1;
}
}
set_array(&array1[0]);
for(int i = 0; i < 4; i++) {
for(int j = 0; j < 9; j++) {
printf("%d ", *(*(array1 + i) + j));
//printf("%d ", array1[i][j]);
}
puts("\n");
}
return 0;
}
void set_array(int array[][9]) {
for(int i = 0; i < 4; i++) {
for(int j = 0; j < 9; j++) {
array[i][j] = 1;
}
}
};
here array1 is having the address of whole array of 1st row(or column)depending upon implementation.
(&array1[0])is same as(array1)of type()[n]sice array name itself contains the address of the ist element .But when you pass(&array)which of type()[m][n]and compiler will throw an error because mismatch of argument type.I think you haven’t read my comments in the last question you asked