在一家公司做实习生,努力学习,keep moving。
//c1.h
1 typedef struct { 2 char tansID[2+1]; 3 int (*tr)(); 4 } trans;
//c1.c
1 #include<string.h> 2 #include<stdlib.h> 3 #include <stdio.h> 4 #include "c1.h" 5 int pf1(){ 6 printf("this is pf1! "); 7 return 1; 8 } 9 int pf2(){ 10 printf("this is pf2! "); 11 return 1; 12 } 13 14 15 int main() 16 { 17 trans t1[2]; 18 memset(t1,0x00,sizeof(t1)); 19 memcpy(t1[0].tansID,"00",2); 20 t1[0].tr = pf1; 21 memcpy(t1[1].tansID,"01",2); 22 t1[1].tr = pf2; 23 24 t1[0].tr(); 25 t1[1].tr(); 26 }