1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <io_utils.h> 4 5 // 1 6 int *(f1(int, double)); 7 8 // 2 9 int (*f2)(int, double); 10 11 // 3 12 int *(*f3)(int, double); 13 14 // 4 15 // int (*f4)(int, double)[]; 16 17 // 5 18 // int (*f5)[](int, double); 19 20 typedef int (*Func)(int, double); 21 22 typedef int Boolean; 23 typedef int *IntPtr; 24 typedef int IntArray[]; 25 26 int Add(int left, double right) { 27 return (int) (left + right); 28 } 29 30 void InitPointer(int **ptr, int length, int default_value) { 31 *ptr = malloc(sizeof(int) * length); 32 for (int i = 0; i < length; ++i) { 33 (*ptr)[i] = default_value; 34 } 35 } 36 37 int main() { 38 int a; 39 IntPtr p; 40 IntArray players = {1,3,4,5}; 41 PRINT_HEX(&main); 42 PRINT_HEX(&InitPointer); 43 44 void (*func)(int **ptr, int length, int default_value) = &InitPointer; 45 46 func(&p, 10, 0); 47 InitPointer(&p, 10, 0); 48 49 (*func)(&p, 10, 0); 50 (*InitPointer)(&p, 10, 0); 51 52 53 PRINT_INT_ARRAY(p, 10); 54 55 free(p); 56 57 Func func1 = &Add; 58 int result = func1(1, 3.0); 59 PRINT_INT(result); 60 return 0; 61 }
标签:10,typedef,int,double,ptr,C语言,typeof,函数指针,InitPointer From: https://www.cnblogs.com/liumy/p/17091758.html