A pointer to a function explination please?
I've never seen this before and im confused as to what does it do and what is it equivalent to? Im learning how to create Binary Search Trees in C with the structure as follows ``` typedef int ElementType; typedef struct treeNode { ElementType data; struct treeNode *left; struct treeNode *right; }TREE; ``` and im reading on the internet and i come across this function ``` TREE *createNode() { TREE *tempNode; tempNode = malloc(sizeof(TreeNode)); tempNode->element = 0; tempNode->left = NULL; tempNode->right = NULL; return tempNode; } ``` What does a pointer to a function do? I'm confused.
And why is it used too.
Not something I could sum up, but take a look at this: http://www.cprogramming.com/tutorial/function-pointers.html
The very bottom of this gives a shorter example: http://www.cplusplus.com/doc/tutorial/pointers/
Join our real-time social learning platform and learn together with your friends!