STATIC.x

Kunal Dawn


Leave a comment

Function Pointers and Callbacks in C — An Odyssey

A pointer is a special kind of variable that holds the address of another variable. The same concept applies to function pointers, except that instead of pointing to variables, they point to functions. If you declare an array, say, int a[10]; then the array name a will in most contexts (in an expression or passed as a function parameter) “decay” to a non-modifiable pointer to its first element (even though pointers and arrays are not equivalent while declaring/defining them, or when used as operands of the sizeof operator). In the same way, for int func();funcdecays to a non-modifiable pointer to a function. You can think of func as a const pointer for the time being. Continue reading

Advertisements