C 语言中的指针函数写法

时间:2021-06-30 18:21:24   收藏:0   阅读:0

指针函数

#include <stdio.h>
#define uint8           unsigned char
#define uint16          unsigned short
#define uint32          unsigned int

uint8 get_device_type_flash() { 
    printf("--------------- run ------------------ \n");
    return 100;
}
uint8 get_flash_1byte(void * funtype){
    uint8 (* fun)() = funtype;
    uint8 num = fun();
    return num;
}
uint8 get_device_type() { return get_flash_1byte(get_device_type_flash); }

int main(int argc, char const *argv[])
{
    uint8 num = get_device_type();
    printf("res: %d \n", num);
    return 0;
}

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!