In-depth understanding of pointer functions 2

Source: Internet
Author: User

#include <stdio.h>intFUNC3 (inti) {     returni;}int(*ff (inti)) (intx) {printf ("%d\n", i); returnfunc3;}intMain () {printf ("%d\n", FF (2)(3)); return 0;}

declare a function pointer, and the return value of the function is also a function pointer to go from:http://www.cnblogs.com/super119/archive/2011/03/26/1996145.htmlfunc is a function pointer, the function return value is int, there is no input parameter, then the main program declares a function pointer myfuncpointer, the function pointer represents a function input parameter is an int, the return value is a function pointer, the type is the Func type. So we can assign the FUNC2 function to the Myfuncpointer pointer. Interview's topic is to myfuncpointer the statement of the pointer. */#include<stdio.h>typedefint(*func) ();//declaring a function pointer with a return value of int, without parameters    intfunc3 () {printf ("In function 3......\n"); return 0; }     //function pointer with a return value of funcFunc Func2 (inta) {printf ("input parameter is:%d\n", a); returnfunc3; }      intMain () {//defines a function pointer with a return value of Func, with an int type argument//This is where you assign the address of the function Func2 to MyfuncpointerFunc (*myfuncpointer) (int) =Func2; //defines a variable that returns a Func type and assigns an initial value to itFunc returnvalue = Myfuncpointer (1111); //define a variable with a return value of type int        intFunc3_return =returnvalue (); printf ("Func3 return value is:%d\n", Func3_return); return 0; }

In-depth understanding of pointer functions 2

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.