1, first give an interview question:
#include "stdafx.h"
#include "stdio.h"
Realize the value of the self increase 1
INT Inc (int a)
{
return (++A);
}
To achieve a multiplication of numeric values
Intmulti (INT*A,INT*B,INT*C)
{
return (*C=*A**B);
}
Defines a function type FUNC1, which has an integer parameter that returns an int type data. At this point FUNC2 is a function type.
Typedefint (FUNC1) (int in);
Defines a function type FUNC2, which has three integer pointer parameters, and returns an int type data. At this point FUNC2 is a function type.
typedef int (FUNC2) (int*,int*,int*);
void Show (Func2*fun,int arg1, INT*ARG2)
{
FUNC1 *p=inc; Defines a function pointer to int Inc (int a)
int temp =p (arg1);//temp=arg1+1;
Fun (&TEMP,&ARG1,ARG2); The Fun function type contains three parameters
printf ("%d\n", *arg2);
}
int main (int argc,char* argv[])
{
int A;
Show (Multi,10,&a); Value is 10*11=110
return 0;
}
2, the above code in the
Defines a function type FUNC1, which has an integer parameter that returns an int type data. At this point FUNC2 is a function type.
Typedefint (FUNC1) (int in);
Defines a function type FUNC2, which has three integer pointer parameters, and returns an int type data. At this point FUNC2 is a function type.
typedef int (FUNC2) (int*,int*,int*);
The reference method is:
FUNC1 *p=&inc;
FUNC2 *fun=&multi;
You can also define the form as a function pointer:
Defines a function pointer of type FUNC1, which points to a formal parameter with an int type and returns a function of type int, at which point FUNC1 is a function pointer
Typedefint (*FUNC1) (int in);
Defines a function pointer of type FUNC2, which points to a formal parameter with only three int* types, and returns a function of type int, at which point FUNC2 is a function pointer
typedef int (*FUNC2) (int*,int*,int*);</span>
The reference method is:
FUNC1 p=&inc;
FUNC2 fun=&multi;
3, in the use of the process, the middle bracket remember to use.