In the code, I omitted parameters for int (*bar) and assigned &foo, which as 3 arguments, to bar. (*bar) received the numbers and gave me a return value. I thought this is ok but I've heard that this is actually UB. How does (*bar) receive the numbers? Thx
#include <stdio.h>
int foo(int a, int b, int c){
return a+b+c;
}
int main(void) {
int (*bar)() = &foo;
printf("%d", bar(1, 2, 3));
return 0;
}
edit
When I pass more than three arguments to bar() (say 5 arguments), the program works. Where do the two extra arguments go?