
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
Function Pointer in C
Function Pointers point to code like normal pointers.
In Functions Pointers, function’s name can be used to get function’s address.
A function can also be passed as an arguments and can be returned from a function.
Declaration
function_return_type(*Pointer_name)(function argument list)
Example
#include<stdio.h> int subtraction (int a, int b) { return a-b; } int main() { int (*fp) (int, int)=subtraction; //Calling function using function pointer int result = fp(5, 4); printf(" Using function pointer we get the result: %d",result); return 0; }
Output
Using function pointer we get the result: 1
- Related Articles
- Function pointer to member function in C++
- Double Pointer (Pointer to Pointer) in C
- How to declare a pointer to a function in C?
- Declare a C/C++ function returning pointer to array of integer function pointers
- Calling a member function on a NULL object pointer in C++
- How to assign a pointer to function using C program?
- Explain the concept of pointer to pointer and void pointer in C language?
- Pointer Arithmetic in C/C++
- How to define pointer to pointer in C language?
- NULL pointer in C
- void pointer in C
- Explain the concept of Array of Pointer and Pointer to Pointer in C programming
- Differentiate the NULL pointer with Void pointer in C language
- C/C++ Pointer Puzzle?
- Pointer vs Array in C

Advertisements