By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,189 Members | 903 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,189 IT Pros & Developers. It's quick & easy.

Function pointers

P: 1
I am a beginner in C language ,Can you say me what is the difference between an ordinary function and a function pointer.How function pointer is advantageous over normal functions.

Nov 1 '06 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 8,916
Well I function is a function.

A function pointer is not a function at all, it is a variable containing the location of a function.

Function pointers are useful when you wish to be able to pass a function to another piece of code so that it can call the function provided. A general example of this is callback functions, you call a function with some data including a pointer to a function. Under certain circumstances the called function then calls the function you have provided a pointer to.

A specific example of this is qsort. qsort sorts any array given the number of elements and the size of the elements in the array and a pointer to a comparison function.
Nov 1 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.