Simple meanings of function pointers, pointer functions, and callback functions in C Language

Source: Internet
Author: User

1. pointer function: Refers to a function whose return value type is a pointer type. Essentially, it is a function, such as int * function (void). Here it can be considered as int * function (void ); the return value is int *, which is a pointer.

2. function pointer: essentially a pointer, But it points to a function, which is called a function pointer, such as int (* function) (void ).

It can be seen from this that the terms pointer function and function pointer can be different from the following two words: function or pointer.

In addition, function pointers have two purposes: Calling functions and making function parameters.

[Cpp]
Int func (int x); // declare a function
Int (* fp) (int x); // defines a function pointer.
Fp = func; // assign the first address of the func function to the pointer fp

Int func (int x); // declare a function
Int (* fp) (int x); // defines a function pointer.
Fp = func; // assign the first address of the func function to the pointer fp
3. Callback Function: a function called using a function pointer. If you pass the pointer (address) of a function as a parameter to another function, when this pointer is used to call the function to which it points, we will say this is a callback function.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.