加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – int(* f [])(int *)代表什么?

发布时间:2020-12-16 10:41:20 所属栏目:百科 来源:网络整理
导读:这是考试问题之一,目标是确定该课程的内容.我真的很困惑int(* f [])(int *)= {f1,f2,f1};是.我教过它可能是一个数组,其元素是括号中函数的结果,这些结果是指向int的地址. 你能解释一下吗? 而且,函数f [i]进入的参数是什么 for(i = 0; i 2; a = fx(f [i],a))
这是考试问题之一,目标是确定该课程的内容.我真的很困惑int(* f [])(int *)= {f1,f2,f1};是.我教过它可能是一个数组,其元素是括号中函数的结果,这些结果是指向int的地址.

你能解释一下吗?

而且,函数f [i]进入的参数是什么

for(i = 0; i <2; a = fx(f [i],a)); 问题:

int f2(int *p) { return *p-- + 2; }

int f1(int *q) { return ++*q; }

int fx(int (*pf)(int*),int q) {
    int t = q;
    while ((t = pf(&q)) % 2) q+=2;
    return t;
}

#include <stdio.h>

void main() {
    int a = 4,b = 3,*p = &b,i;
    int (*f[])(int*) = {f1,f1 };

    for (i=0; i<2; a += **fx(f[i++]**,a));
    printf("%d",a + *p);
}

解决方法

应用 clockwise/spiral rule

int (*f[])(int*)
      ^                f is

int (*f[])(int*)
      ^^^              f is an array

int (*f[])(int*)
    ^^^^^^             f is an array of pointers

int (*f[])(int*)
    ^^^^^^^....^       f is an array of pointers to functions


int (*f[])(int*)
    ^^^^^^^^^^^^       f is an array of pointers to functions
                       that accept a pointer to int

int (*f[])(int*)
^^^^^^^^^^^^^^^^       f is an array of pointers to functions
                       that accept a pointer to int and return a int value

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读