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; }
查看全文
相关阅读:
TeX中的引号
竖式问题
蛇形填数
开灯问题
排列
分数化小数
子序列的和
cookie
post请求
get请求
原文地址:https://www.cnblogs.com/jjtx/p/2533492.html
最新文章
237. Delete Node in a Linked List删除链接列表中的节点
翻转链表reverse linked list:全部
翻转链表reverse linked list:全部,m~n
686. Repeated String Match 字符串重复后的子字符串查找2
125. Valid Palindrome判断有效的有符号的回文串
344. Reverse String 最基础的反转字符串
Maximum Depth of Binary Tree二叉树的最大深度
Python爬虫学习==>第四章:MySQL的安装
Python爬虫学习==>第三章:Redis环境配置
Python爬虫学习==>第二章:MongoDB环境配置
热门文章
Python爬虫学习==>第一章:Python3+Pip环境配置
重学Python
重学Python
python3速查参考- python基础 5 -> 常用的文件操作
python3速查参考- python基础 4 -> 元组 + 字典 + 字符串 的学习
python3速查参考- python基础 3 -> -> while循环实例 + Continue && break的应用 + 列表的初步学习
python3速查参考- python基础 2 -> if语句应用 + while循环应用
猜数字游戏的提示
回文词
WERTYU
Copyright © 2011-2022 走看看