'difference between calling a function when it is pointed by a pointer and not pointed by a pointer
Solution 1:[1]
In (1), main calls go and passes the address of foo in the call. In (2), main calls go and does not pass any argument. (foo designates the function foo. However, when a function designator is used in an expression other than as the operand of sizeof or of unary &, it is automatically converted to a pointer to the function. So go(foo) is equivalent to go(&foo).)
In (1), go takes a parameter that is a pointer to a function with unspecified parameters and return type void. In (2), go does not take any parameters.
In (1), go calls the function whose address it was passed, by using its parameter proc. In (2), go calls foo. (As above, although foo is used in foo();, it is automatically converted to an address, as if (&foo)(); had been written. All function calls actually use the address of the function, even if function designator is used.)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Eric Postpischil |

