ProgrammingVery hard
Which parameter declaration accepts an int a[3][4] argument from main without a warning?
- A. void f(int (*m)[4]);
- B. void f(int **m);
- C. void f(int *m[5]);
- D. void f(int m[][3]);
Correct answer: A. void f(int (*m)[4]);
An int[3][4] decays to a pointer to its first row, an int (*)[4]. int ** is a different type, and int *m[4] is an array of pointers; int m[][3] fixes the wrong row width.
More C Programming questions
- On an n x n grid with n = 4, how many cells lie on at least one of the two main diagonals?
- int a[2][2] = {1, 2, 3, 4}; What is a[1][0]?
- int a[2][3]; What is sizeof(a[1]) on a platform with 4-byte int?
- How many trailing zero bits does 96 have? (96 is 1100000 in binary.)
- What is the index of the highest set bit of 1000 (so 2^index is the largest power of two that is at most 1000)?
- uint16t x = 0x0F00; uint16t y = x & (uint16t)(0u - x); What is y?