You must tell the function the bound of an array, otherwise, elements cannot be accessed if the array is a variable-length one, it may be difficult to know the bound
| 5 | // otherwise, elements cannot be accessed |
| 6 | // if the array is a variable-length one, it may be difficult to know the bound |
| 7 | void init_2d_array(float mat[][4], //error, arrays of unknown bound |
| 8 | size_t rows, size_t cols) |
| 9 | { |
| 10 | for (int r = 0; r < rows; r++) |
| 11 | for(int c = 0; c < cols; c++) |
| 12 | mat[r][c] = r * c; |
| 13 | } |
| 14 | |
| 15 | int main() |
| 16 | { |
nothing calls this directly
no outgoing calls
no test coverage detected