MCPcopy Create free account
hub / github.com/ShiqiYu/CPP / init_2d_array

Function init_2d_array

week04/examples/md-array.cpp:7–13  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

5// otherwise, elements cannot be accessed
6// if the array is a variable-length one, it may be difficult to know the bound
7void 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
15int main()
16{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected