Bifalgorithm post · Computer science one · Function Pointers
How are function pointers declared and used in C?
How are function pointers declared and used in C? (Computer science one · Function Pointers) — "18.2.2. Function Pointers\n\nFunctions are just pieces of code…
Ideas in this flowchart
- Function pointers
- Functions are pieces of code stored somewhere in memory, like variables.
- A function pointer is a variable that points to a function.
- Declaring a function pointer requires its return type and parameter list.
- The syntax can describe a pointer to the sqrt() function, which takes one double and returns a double.
- double (*ptrToSqrt)(double) = NULL;
- The pointer is named ptrToSqrt and is initialized to NULL.
- ptrToSqrt = sqrt;
- A function's identifier acts as a pointer to that function.
- A function can be invoked through its pointer like any other function call.