print_data.c
- /* Copyright(C) 2012 for free
- * All right reserved
- */
- /**
- * @file print_any_data.c
- * @synopsis print any data
- * @author sense, linuxboy2008@gmail.com
- * @version 1.0
- * @date 2012-07-02
- */
- #include <stdio.h>
- #include <stdlib.h>
- typedef void(*Print)(void *data);
- #pragma message("it's start to complie ...") //测试编译之用
- void print_int(void *data)
- {
- printf("%d\n",*(int*)data);
- }
- void print_char(void *data)
- {
- printf("%s\n",(char *)data);
- }
- void dist_print(void *data,Print print)
- {
- print(data);
- }
- int main(int argc,char **argv)
- {
- int a = 5;
- char *b = "hello,world";
- dist_print(&a,print_int);
- dist_print(b,print_char);
- return 0;
- }
测试:
gcc -g -Wall print_data.c -o print_data
阅读(793) | 评论(0) | 转发(0) |