zoukankan
html css js c++ java
函数指针
1、常见的用法
#include <stdio.h> typedef int (*PFUN)(int, int); // PFUN 是函数指针类型 int fun(int a, int b) { return a + b; } int main(void) { PFUN pf = fun; // 或 PFUN pf = &fun; printf("%d\n", pf(1, 2)); printf("%d\n", (*pf)(1, 2)); return 0; }
2、第二种用法
#include <stdio.h> typedef int FUN(int, int); // FUN 是函数类型 int fun(int a, int b) { return a + b; } int main(void) { FUN *pf = fun; // 或 FUN *pf = &fun; printf("%d\n", pf(1, 2)); printf("%d\n", (*pf)(1, 2)); return 0; }
3、关于函数指针的类型
#include <stdio.h> typedef int FUN(int, int); int fun(int a, int b) { return a + b; } int main(void) { // (int (*)(int, int)) pf; // 错误,不能这样定义变量 FUN *pf; pf = (int (*)(int, int))1; // 强制类型转换,可以 pf = fun; printf("%d\n", pf(1, 2)); printf("%d\n", (*pf)(1, 2)); return 0; }
查看全文
相关阅读:
《the art of software testing》 第三章 人工测试
unbutu下wireshark编译安装(已更新)
Cygwin工具的简单使用
第三周Linux编程实例练习
ceph如何快速卸载所有osd及擦除磁盘分区表和内容并重新加入
Redis集群的分布式部署
redis主从同步
redis编译安装
kubeadm部署k8s
openstack高可用集群19-linuxbridge结合vxlan
原文地址:https://www.cnblogs.com/jjtx/p/2533492.html
最新文章
MyAdvice 填充方法(在原有方法上添加方法)
Spring 框架XML文件的配置文件
@ 添加属性(属性注入)
Spring 添加属性集中常见方法
system函数
进程控制(四)
进程的一生
进程控制(三)
进程控制(二)
堆和栈的区别(转)
热门文章
进程控制(一)
打算读的书
系统级I/O
Linux的硬链接和软链接
十一月份读书计划
wireshark抓取qq数据包
《the art of software testing》第六章
《the art of software testing》第五章
su 和sudo su 的区别
《the art of software testing》第四章 测试用例的设计
Copyright © 2011-2022 走看看