Pointers to pointers and functions.
Distinguish arrays of pointers, pointer-to-array types, and callbacks.
The idea behind the syntax.
C declarators can look dense because the same symbols describe different shapes. An array of pointers stores several pointer values; a pointer to an array points to one complete array object. Their memory layouts differ. A char *names one position in character storage, while char ** can name an element of an array of character pointers or an object that stores a char pointer. The type alone does not say who owns the text.
A function pointer stores a way to call a function with a particular signature. It can let a sorting routine, event dispatcher, or parser accept a policy chosen by its caller. The callback's parameter and return types must match what the caller expects. A function pointer is distinct from an object pointer; C does not promise that arbitrary casts between them are portable.
What C guarantees.
Parentheses in a declarator change its binding. int *rows[3] is an array of three pointers to int, while int (*row)[3] is a pointer to an array of three int. A typedef can give a complicated function-pointer type a readable name, but the underlying contract remains the same. When an API uses multiple pointer levels, draw the objects and arrows rather than decoding punctuation alone.
The example defines a callback type for converting an integer. The function apply receives a value and a function pointer, then calls through the pointer. The callback does not capture surrounding local variables as a closure would in another language. Extra context, when needed, is commonly passed as a separate void * value whose type and lifetime the API documents.
Why the detail matters.
The declaration grammar can be read by grouping what is closest to the identifier. Brackets bind more tightly than *, so int *rows[3] describes rows as an array first, with each element a pointer. Parentheses in int (*row)[3] make the pointer operator bind first, so row points to one entire three-int array. The layouts are different even when both permit a familiar-looking indexed access in some contexts. Draw one box per object before deciding whether an expression is valid.
Function pointers add a similar layer: a callback value identifies executable code with a specific signature. The caller may invoke it later, which means any separate context pointer passed beside it must remain valid until then. Unlike a closure, a plain C function pointer does not carry a captured environment. Libraries commonly pair callback and context arguments to create that effect explicitly. The API must specify when the callback is called and whether it can be retained.
See the rule in context.
#include <stdio.h>
typedef int (*transform_fn)(int);
int twice(int value) { return value * 2; }
int apply(int value, transform_fn transform) {
return transform(value);
}
int main(void) {
printf("Result: %d\n", apply(6, twice));
return 0;
}transform_fn names a pointer to a function taking int and returning int. Passing twice supplies a function with that compatible signature. apply calls it with 6, receiving 12, and returns that value to main. The program displays Result: 12. No dynamic allocation or hidden state is involved; the callback is ordinary code selected through a typed pointer.
Where the rule stops.
A callback cannot safely outlive context data that its API asks it to use. When void * context is involved, the library and caller must agree on its actual type and lifetime.
Keep this model.
Once related data and behavior have clear types, a program can represent domain records. Structs group fields under one name while preserving the same pointer, lifetime, and access rules for each member.