- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction_pointer.c
More file actions
Latest commit
executable file
·39 lines (29 loc) · 611 Bytes
/
Copy pathfunction_pointer.c
File metadata and controls
executable file
·39 lines (29 loc) · 611 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<stdio.h>
intfunc1(void){
printf("hello from func1\n");
return1;
}
intfunc2(void){
printf("hello from func2\n");
return0;
}
charfuncBool(inta){
printf("hello from funcBool, a=%d\n", a);
return'a';
}
intmain(void){
/// take note func1=&func1, both are same!
int (*pFuncPtr[3])(void) = { func1, func2, &func2};
(*pFuncPtr[0])();
(*pFuncPtr[1])();
(*(pFuncPtr+1))();
(*(pFuncPtr+0))();
printf("with ampersand!\n");
(*pFuncPtr[2])();
typedefchar (*pFuncBool)(int);
pFuncBoolmyFuncBool=&funcBool;
(*myFuncBool)(1);
int (*vfp)(void) =&func1;
(*vfp)();
return0;
}