Question 1
Back to Exercise
The program below has a bug. Which statement correctly describes it?
#include <stdio.h>
int make(void)[3];
int main(void) {
printf("ok\n");
return 0;
}
- A The array size must be a variable
- B C functions cannot return arrays; return a pointer to an array (int (*make(void))[3]) or a struct that contains one Correct
- C make needs a parameter
- D There is no bug
Correct Answer: Option B
Arrays are not assignable values in C, so they cannot be returned. Wrapping the array in a struct is the usual way to return it by value.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!