ProgrammingVery hard
Which prototype is valid in C99 for a function that takes a column count c and an int matrix m with c columns?
- A. void f(int m[][c], int c);
- B. void f(int m[][], int c);
- C. void f(int c, int m[][c]);
- D. void f(int m[3][], int c);
Correct answer: C. void f(int c, int m[][c]);
A variable-length array parameter may use an earlier parameter as its size. The size c must be declared before the array that uses it, and the inner dimension can not be left empty.
More C Programming questions
- For int a[1000][1000], which loop walks memory in address order (the cache-friendly order)?
- Which declaration makes a 10^6 int matrix at run time without depending on the stack size?
- For a matrix of size n x n with n = 500, which algorithm is correct and fast enough within 1 second for C multiplication?
- Given int a[3][4] and int q = &a[0][0], which element does q[5] refer to?
- int m[2][3] = {{1}, {2, 3}}; What is m[0][0] + m[1][0] + m[1][1] + m[0][2]?
- int a[3][4]; what do sizeof a / sizeof a[0] and sizeof a[0] / sizeof a[0][0] give?