Ask your own question, for FREE!
Computer Science 17 Online
OpenStudy (anonymous):

A pointer to a function explination please?

OpenStudy (anonymous):

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.

OpenStudy (anonymous):

And why is it used too.

OpenStudy (e.mccormick):

Not something I could sum up, but take a look at this: http://www.cprogramming.com/tutorial/function-pointers.html

OpenStudy (e.mccormick):

The very bottom of this gives a shorter example: http://www.cplusplus.com/doc/tutorial/pointers/

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!