函数指针和指针函数用法和区别

参考链接:

函数指针和指针函数用法和区别_luoyayun361的专栏-CSDN博客_指针函数

指针函数与函数指针(C语言) - 简书

指针函数:指针函数_百度百科

# include <stdio.h>
# include <string.h>
# include <iostream>
using namespace std;
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_s("%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;
}
//形参pointer是指针指向包含4个元素的一维数组的指针变量
float* find(float(*pionter)[4], int n)/*定义指针函数*/
{
    float* pt;
    pt = *(pionter + n);
    return(pt); //pt是一个指针变量,它指向浮点型变量。
}

函数指针:函数指针_百度百科

#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_s("%d%d", &a, &b);
    c = (*ptr)(a, b);
    printf("a=%d, b=%d, max=%d", a, b, c);
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值