ProgrammingVery hardProduct company OA
Read the declaration:
Read the declaration:
char *(*(*x)[4])(int);What is `x`?
- A. An array of 4 pointers to functions that take an int and return a pointer to char *
- B. A pointer to a function that takes an int and returns an array of 4 char * values
- C. A pointer to an array of 4 pointers to functions that take an int and return char *
- D. A function that takes an int and returns a pointer to an array of 4 char * values
Correct answer: C. A pointer to an array of 4 pointers to functions that take an int and return char *
Start at the name and respect parentheses: (*x) – x is a pointer; [4] – to an array of 4; the next * – of pointers; (int) – to functions taking int; char * – returning char *. A call through it looks like (*(*x)[i])(n). Without the inner parentheses, *x[4] would make x an array first; and a function can never return an array, which rules out the third option.
More C Programming questions
- What is printed? c char a[8] = "abcdefg"; memmove(a + 2, a, 4); char b[6] = "XXXXX"; strncpy(b, "hi", 4); char c[4]; strncpy(c, "wxyz"…
- What is printed? c struct N { int v; struct N next; }; struct N n[5] = {{1, n + 1}, {2, n + 2}, {3, n + 3}, {4, n + 4}, {5, 0}}; struct N…
- What is printed? c int lb(const int a, int n, int x) { int lo = 0, hi = n; while (lo < hi) { int mid = lo + (hi - lo) / 2; if (a[mid] < x)…
- What is printed? c int a = 7, b = 2; double x = a / b; double y = (double)a / b; double z = (double)(a / b); int w = (int)(-3.7) +…
- What is printed? c enum { RED = 2, GREEN, BLUE = GREEN + 4, N }; int a[] = { [RED] = 5, [BLUE] = 1, 9, [GREEN] = 6, 4 }; printf("%zu %d %d…
- Assume 8-bit char, 16-bit unsigned short and 32-bit int. What is printed? c int big = 300; unsigned char uc = big; unsigned short us = -1…