V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
cfans1993
V2EX  ›  问与答

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

  •  
  •   cfans1993 · Aug 19, 2015 · 2359 views
    This topic created in 3905 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
        1
    bestsanmao  
       Aug 19, 2015
    这行想干嘛
    int (*f )(int,int );
    weyou
        2
    weyou  
       Aug 19, 2015   ❤️ 1
    f = max;
    hncqp
        3
    hncqp  
       Aug 19, 2015 via iPhone
    g 函数指针
    comicfans44
        4
    comicfans44  
       Aug 19, 2015   ❤️ 1
    int (*f )(int,int )=max;
    int c=f (1,4 );
    attitude
        5
    attitude  
       Aug 19, 2015
    好好学习下函数指针该怎么用
    townboy
        6
    townboy  
       Aug 19, 2015
    多看书,多 google 。
    int (*f )(int,int ); 只是定义,没有赋值
    zackkson1991
        7
    zackkson1991  
       Aug 19, 2015
    建议 C 语言深度剖析这本书!
    wlee1991
        8
    wlee1991  
       Aug 19, 2015
    main 程序都看不到 max 的字眼,我也是醉了。。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2675 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 15:57 · PVG 23:57 · LAX 08:57 · JFK 11:57
    ♥ Do have faith in what you're doing.