指针函数与函数指针
来源:互联网 发布:ipad 电容笔 知乎 编辑:程序博客网 时间:2024/06/03 02:17
学数据结构用到了指针函数,查阅资料作个总结.
1.指针函数
顾名思义,就是一个带有指针的函数,本质是一个函数。返回值为某一类型的指针。
举例:
#include <stdio.h> float *find(float(*pionter)[4],int n);//函数声明 int main(void) { static float score[][4]={{60,70,80,90},{56,89,34,45},{34,23,56,45}}; float *p; int i,m; printf("Enter the number to be found:"); scanf("%d",&m); printf("the score of NO.%d are:\n",m); p=find(score,m-1); for(i=0;i<4;i++) printf("%5.2f\t",*(p+i)); return 0; } float *find(float(*pionter)[4],int n)/*定义指针函数*/ { float *pt; pt=*(pionter+n); return(pt); }
find 返回了一个指针
2.函数指针即为指向函数的指针变量,其本质为指针。举例:
#include<stdio.h>int max(int x,int y){return (x>y? x:y);}int main(){ int (*ptr)(int, int); int a, b, c; ptr = max; scanf("%d%d", &a, &b); c = (*ptr)(a,b); printf("a=%d, b=%d, max=%d", a, b, c); return 0;}此例利用了指针来接收返回值。
0 0
- 指针函数与函数指针
- 指针函数与函数指针
- 函数指针与指针函数
- 指针函数与函数指针
- 函数指针与指针函数
- 函数指针与指针函数
- 函数指针与指针函数
- 函数指针与指针函数
- 函数指针 与 指针函数
- 函数指针与指针函数
- 函数指针与指针函数
- 函数指针与指针函数
- 函数指针与指针函数
- 函数指针与指针函数
- 函数指针与指针函数
- 函数指针与指针函数
- 函数指针与指针函数
- 指针函数与函数指针
- [Leetcode]201. Bitwise AND of Numbers Range @python
- Java实现任意矩阵Strassen算法
- 使用DataGridView进行增删改查 并同步到数据库
- Android中AsyncTask使用详解
- 第7讲项目3——发工资
- 指针函数与函数指针
- 单片机片内存储器烧写
- 数据结构实验之排序四:寻找大富翁
- 图(最短路径)1
- 阿里云虚拟主机下载AKP失败解决办法
- zoj1025 dp(呃。。)
- 线程同步
- LightOJ 1007 - Mathematically Hard (欧拉筛+预处理前缀和)
- GDB多线程调试方法