Function pointer call Method

Source: Internet
Author: User
First go to the instance for analysis

# Include <stdio. h>
Void myfun (void );
Int main (void)
{
Void (* PF) (void );
PF = myfun;/* can also be assigned as follows: pF = & myfun; the same principle */
(* PF )();
PF ();
Return 0;
}
Void myfun (void)
{
Printf ("Hello world! \ N ");
}

Method 1: because pf points to the myfun function, * PF is the myfun function, so the expression (* PF) () is the same as myfun.
From the declaration of myfun and PF, we can see that myfun and (* PF) are equivalent.
Method 2: because the function name is a pointer, pointers and function names can be used interchangeably. Therefore, PF () is the same as myfun.
From the PF assignment statement, we can see that PF and myfun are equivalent.

This is the historical reason for C's development process. It represents the different views of the two groups!

However, the most critical point is that the C standard accepts both of them as equivalent form !!!

Function pointer call Method

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.