cfans1993
V2EX  ›  问与答

C 语言函数指针,调用对应的函数后,返回值无法赋给一个局部变量

  •  
  •   cfans1993 · Aug 19, 2015 · 2684 views
    This topic created in 4104 days ago, the information mentioned may be changed or developed.

    如下,注释的那一行编译通不过,不知要怎么修改

    int max (int a,int b ){
        return a>b?a:b;
    }
    
    int main ()
    {
        int (*f )(int,int );
        int c=(*f )(1,4 );  //这行编译通不过
        printf ("%d",c );
        return 0;
    }
    
    Supplement 1  ·  Aug 20, 2015
    没有加 f=max
    这么明显的错误,好想回妈妈肚子里改造
    😂😂😂😂
    8 replies  •  2015-08-19 20:37:17 +08:00
    bestsanmao
    bestsanmao
    Aug 19, 2015
    1
    这行想干嘛
    int (*f )(int,int );
    weyou
    weyou
    Aug 19, 2015❤️1
    2
    f = max;
    hncqp
    hncqp
    Aug 19, 2015 via iPhone
    3
    g 函数指针
    comicfans44
    comicfans44
    Aug 19, 2015❤️1
    4
    int (*f )(int,int )=max;
    int c=f (1,4 );
    attitude
    attitude
    Aug 19, 2015
    5
    好好学习下函数指针该怎么用
    townboy
    townboy
    Aug 19, 2015
    6
    多看书,多 google 。
    int (*f )(int,int ); 只是定义,没有赋值
    zackkson1991
    zackkson1991
    Aug 19, 2015
    7
    建议 C 语言深度剖析这本书!
    wlee1991
    wlee1991
    Aug 19, 2015
    8
    main 程序都看不到 max 的字眼,我也是醉了。。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2009 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 52ms · UTC 15:11 · PVG 23:11 · LAX 07:11 · JFK 10:11
    ♥ Do have faith in what you're doing.