Function Pointers and its Confusing Notations
Function Pointers
Pointers to functions can be assigned, placed in arrays, passed into functions, returned by functions and so on. (basically like a normal pointer)
Format: RETURN_TYPE (*NAME)(INPUT_ARGS)
The () are needed for NAME as without it, it now means a function who’ll return a pointer pointing to a value of RETURN_TYPE.
Weird Function Pointer Notations
Some examples of function pointers:
int (*f)(): A pointer to a function returningintchar (*(*x())[])():xis a function returning pointer toarray[]((*x())[]) of pointer to function returningchar(char (*x . . . ])())char (*(*x[3])())[5]:xis anarray[3]of pointer ((*x[3])) of a function returning pointer toarray[5]ofchar.
This thing is basically like throwing functions around in Python, except with the extra syntax of pointers.
#C #C/features #C/conceptual