-
What will be the output of the following C code?
#include <stdio.h>
#include <stdarg.h>
int fun(...);
int main()
{
char ch = 99;
fun(ch);
return 0;
}
int fun(...)
{
va_list list;
char ch = va_arg(list, char);
printf("%c\n", ch);
}
-
- c
- 99
- Undefined behaviour
- Compilation Error
- None of these
Correct Option: D
Compilation Error
main.c:3:13: error: ISO C requires a named argument before ‘...’
int fun(...);
^~~
main.c:10:13: error: ISO C requires a named argument before ‘...’
int fun(...)
^~~
In file included from main.c:2:0:
main.c: In function ‘fun’:
main.c:13:32: warning: ‘char’ is promoted to ‘int’ when passed through ‘...’
char ch = va_arg(list, char);
^
main.c:13:32: note: (so you should pass ‘int’ not ‘char’ to ‘va_arg’)
main.c:13:32: note: if this code is reached, the program will abort