-
What will be the output of the following C code?
#include <stdio.h>
void function(int);
void (*fun)(void) = function;
int main(int argc, char *argv[])
{
fun(20);
return 0;
}
void function(int k)
{
printf("%d\n", k);
}
-
- Compilation Error
- Garbage value
- 20
- Runtime Error
- None of these
Correct Option: A
Compilation Error
main.c:3:25: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
void (*fun)(void) = function;
^~~~~~~~
main.c: In function ‘main’:
main.c:6:9: error: too many arguments to function ‘fun’
fun(20);