when do we need pointer to function?
This is a discussion on pointer to function within the C Programming forums, part of the General Programming Boards category; when do we need pointer to function?...
when do we need pointer to function?
When we pass it as a parameter to another function. It could then be executed from within that without that function knowing or caring which specific function is being used.
When we have an array of such function pointers and we want to index into that array via some formula... for fast multi-function choice. Such as for optimized interpreters, dynamic algebraic expression executers, etc.
Some standard functions, being passed a pointer to a function.
man page qsort section 3
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.