LearnFrenzy
Sign in Take a free test

Variable Number of Arguments · Find the Error · Question 3

Error (C17): a function with only ... as parameters Answer, explanation & discussion

  • Find the error
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 3 Back to Exercise

Compiled as C17, why is this program rejected?

main.c
#include <stdarg.h>
#include <stdio.h>

int first(...) {
    return 0;
}

int main(void) {
    printf("%d\n", first(4, 5));
    return 0;
}
  • A first must return void
  • B Before C23 a variadic function needs at least one named parameter before the ellipsis Correct
  • C printf cannot call variadic functions
  • D There is no bug
Correct Answer: Option B

In C17 va_start needs a named parameter to locate the variable part, so f(...) was not allowed. C23 permits it.

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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links