- 1
Assignment, Here pointer is assigned to function or function is assigned to pointer ..??
void (*funptr)(int); /* function pointer */ funptr = say_hello; /* pointer assignment */
6 Respuestas
+ 3
Function is assigned to a pointer
+ 3
Yes you are correct, what actually happens is the function cannot be assigned to a pointer variable because it is a piece of executable code, so that's why function pointer will get assigned to the function rather than the other way around.
+ 3
Nope, say_hello is a function and funptr is a variable.
It's not possible to assign any value or variable to a function (a piece of executable code).
Assigning function pointer to some function means that the function pointer has the address of that specific function, which means that function pointer is just pointing to that specific function.
+ 1
nAutAxH AhmAd But in function pointer topic of C in SoloLearn it is written
"The following short program declares a function, declares a function pointer, assigns the function pointer to the function, and then calls the function through the pointer" ....??it is saying pointer is assigned to a function..?
+ 1
Thanku nAutAxH AhmAd
0
But if function pointer will get assigned to the function shouldn't it be like say_hello=funptr; ?