- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
Advertisements