Pointers to Functions Flashcards
Use the following functions:
char func1(char c);
char * func2(char *s);
- How do you delcare a function pointer?
- How do you assign addresses to the funtion pointers?
- How do you invoke the functions using the pointers?
How do you use typedef with a function pointer?
What would you put into the blank box to pass a function pointer into integrate?
What happens when a function name isn’t followed by paraentheses when passed as a parameter into a function?
for example:
result = integrate(sin, 0.0, PI/2);
How would you call a function with a pointer in the body of another function.
Example: function pointer is f which takes x as an argument.
In general, how does the standard library qsort function work? What does it need?
What is the prototype for qsort?
What do each of the parameters need/represent?
In the below example of inventory, how would we call qsort? What would qsort do with the array?
What is the code for compare_parts that can be used to sort the inventory array(3 versions)? What order is it sorted into?
What are the multi uses for function pointers?
What is the code for an array whose elements are function pointers?
What is the code for an example of a call of the function stored in position n of the file_cmd array?