函数指针
来源:互联网 发布:淘宝盗用视频怎么举报 编辑:程序博客网 时间:2024/05/21 04:41
#include <stdio.h>#include <stdlib.h>void hello(){ printf("hello ,Hi!");} int main (void){ void(*fp)()=&hello; /*fp指向hello()的地址*/ fp(); return EXIT_SUCCESS;}
当然,定义的hello()函数中也可以加上传入参数,修改后如下:
#include <stdio.h>#include <stdlib.h>void hello(int a,int b, char *c){ printf("hello ,Hi!");} int main (void){ void(*fp)(int,int,char *)=&hello; fp(0,0,"c"); return EXIT_SUCCESS;}或许看上去函数指针定义比较复杂,可以用typedef关键字修改,修改后如下:
#include <stdio.h>#include <stdlib.h>void hello(){ printf("hello ,Hi!");}typedef void(*SimpleFunc)(); /*使用typedef关键字,给void类型的函数创建一个类型名称SimpleFunc*/int main (void){ SimpleFunc fp=&hello; fp(); return EXIT_SUCCESS;}
0 0
- 指针函数 函数指针
- 函数指针/指针函数
- 指针函数&函数指针
- 函数指针 指针函数
- 函数指针 指针函数
- 指针函数,函数指针
- 函数指针,指针函数,
- 指针函数,函数指针
- 函数指针 指针函数
- 函数指针、指针函数
- 指针函数&函数指针
- 函数指针 指针函数
- 函数指针 指针函数
- 函数指针&指针函数
- 指针函数 函数指针
- 指针函数 &函数指针
- 函数指针&指针函数
- void指针 函数指针
- C#生成Code39条形码【非条形码字体】
- Java编程思想第四章练习7,使用break/return在打印到99时退出
- 字符串
- float浮点数的二进制存储方式及转换
- js区分鼠标单击和双击事件
- 函数指针
- 多线程三(同步代码块)
- android studio基本使用零碎整理
- C#生成Code39条形码【非条形码字体】
- neutron router-update如何增加路由
- Android下得到Home键按下的消息
- C#生成Code39条形码【非条形码字体】
- 黑马程序员 日记(七)
- R语言学习笔记