Typedef void (* Fun) (void );

Source: Internet
Author: User
Int I; // defines an int type variable I. In this case, typedef int; // indicates that you have defined an integer data type int, which is equivalent to int: int II; // defines an int type variable II; void (* PFn) (void) // defines a function pointer, this function pointer points to the function entry address similar to void Foo (void) function typedef void (* Fun) (void) // indicates that you have defined a function pointer data type fun PF; // define a function pointer PF. Change the function pointer to a function similar to void * PF (void). // Leo char * A = "this is "; // allocate a space in the constant area, and a points to the space char a [] = "this is"; // allocate a space in the constant area, then, allocate a space on the stack and copy the content of the constant area. Therefore, you can modify /* ///////// Define a function pointer type ////// // * // For example, you have three functions: void Hello (void) {printf ("Hello! ");} Void Bye (void) {printf (" goodbye! ");} Void OK (void) {printf (" OK! ");} Typdef void (* funcptr) (void); // This constructs a general function. You can use it like this: void speak (int id) {funcptr words [3] = {& hello, & bye, & OK}; funcptr fun = words [ID]; (* Fun, if speak (0) is displayed, "Hello!" Speak (1) will show "Goodbye !" Speak (2) will display "OK !" A group of functions that process parameters and return values in the same form, but have uncertain functions can use function pointers such as arithmetic operators, addition, subtraction, multiplication, and division, can be represented by typedef int (* calc) (INT, INT), etc.




Typedef void (* Fun) (void );

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.