首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

构造体函数指针

2012-12-26 
结构体函数指针#includestdio.htypedef struct{inta intbunsigned int (*init_mptr)(unsigned int ptr

结构体函数指针

#include   <stdio.h>typedef struct                                                                                   
 {                 int  a; int  b;                                                                                           
  unsigned int (*init_mptr)(unsigned int ptr1,unsigned int len);
 } testmap;                                                                                      
unsigned int funtest(unsigned int  ptr1,unsigned int,len)
{                                                            
                                               return len+20+ptr1; }int main(int argc,char *argv[]){  int a,b;                                                                                         
   a=1;                                                                                             
  testmap *test1; testmap test;test1=&test; test1->init_mptr=funtest; printf("\na=%d\n",a);          b=(*(test1->init_mptr))(a,40);                          printf("\nb=%d\n",b);return 0; }       

?

热点排行