How does pointer to pointer to function (**ppf)() differ from pointer to function (*pf)() in C?

I wondering if there is a difference between int (**ppf)(int) and int (*pf)(int) in C.

C has this wierd way of treating function pointers where a function automatically transforms into a pointer to function. That allows programmers to write really wierd stuff.

double (*pf)(double) = ***&*&***&*sin; (******&*&*puts)("Hello, world!");

This is really strange and I do not see how it is useful.

Here are my question(s) about pointer to pointer to function in C.

Does int (**ppf)(void) have more levels of indirection than int (*pf)(void)?

Is there any case where using (**ppf)() is superior to (*pf)()?

Are there any differences between them at all?

Is even it possible to get a pointer to pointer to function in C?

-------------Problems Reply------------

Yes there is a difference in between (**ppf)() and (*pf)(). And pointer to pointer to a function exist in c.

void f();
void (*pf)() = f // or &f
void (**ppf)(e) = &pf;

Any one of the following function call can be used to call function f:
using f: f(); ( &f)(); (*f)(); (**f)(); (***f)();
using pf: pf(); (*&pf)(); (*pf)(); (**pf)(); (***pf)();
using ppf: (*ppf)(); (********ppf)

They're different types. They are even different classes of types; C makes a distinction between object pointers and function pointers. Any function pointer can be assigned to any other function pointer (without a cast), which is not true for object pointers.

Obviously, pf is a function pointer. But a pointer to a function pointer is a pointer to an object, namely, to the function pointer.

Category:c# Views:1 Time:2018-03-12

Related post

Copyright (C), All Rights Reserved.

processed in 0.430 (s). 11 q(s)