Interview Question

What is function pointer?

A function pointer stores a callable function designator with a compatible type.

💡 Concept ✅ Quick Revision ⚙ C

Answer

A function pointer can designate a function with a compatible function type. • It can be called using the pointer expression. • Callbacks and dispatch tables commonly use function pointers. • Calling through an incompatible function type has undefined behavior.

💡 C Example

int square(int value) { return value * value; } int main(void) { int (*operation)(int) = square; return operation(5) == 25 ? 0 : 1; }

⚡ Quick Revision

A function pointer stores a callable function designator with a compatible type.