void (*ptr)(void);
// คือ pointer to function.void *ptr(void);
// คือการประกาศฟังก์ชั่น คืนค่า pointer of void.- การประกาศ pointer to function ต้องใส่วงเล็บรอบชื่อกับ * ทุกครั้ง เพราะ ( ) มีศักดิ์เครื่องหมายสูงกว่า *
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void greeting(); | |
int sum(int a, int b); | |
int main() | |
{ | |
greeting(); | |
void (*ptr)(void) = greeting; | |
printf("%d , %d\n",greeting,ptr); | |
ptr(); | |
int (*pSum)(int, int) = sum; | |
printf("%d , %d\n",sum(2,3),pSum(3,4)); | |
return 0; | |
} | |
void greeting() | |
{ | |
printf("Hello Banyentutorial.\n"); | |
} | |
int sum(int a, int b) | |
{ | |
return a+b; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void greeting(); | |
int sum(int a, int b); | |
int main() | |
{ | |
greeting(); | |
void (*ptr)(void) = greeting; | |
printf("%d , %d\n",greeting,ptr); | |
ptr(); | |
int (*pSum)(int, int) = sum; | |
printf("%d , %d\n",sum(2,3),pSum(3,4)); | |
return 0; | |
} | |
void greeting() | |
{ | |
printf("Hello Banyentutorial.\n"); | |
} | |
int sum(int a, int b) | |
{ | |
return a+b; | |
} |