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

C 函数指针调用格式

  •  
  •   algas · Nov 15, 2017 · 2984 views
    This topic created in 3084 days ago, the information mentioned may be changed or developed.
    下面两种方法都可以正确的调用函数指针,感到非常迷茫,求解答~

    格式 1:
    void test(void (* func)(int a), int b)
    {
    func(b);
    }

    格式 2:
    void test(void (* func)(int a), int b)
    {
    (*func)(b);
    }
    3 replies    2017-11-15 20:41:03 +08:00
    owenliang
        1
    owenliang  
       Nov 15, 2017
    都可以,不要迷茫了,语法而已。
    chinawrj
        2
    chinawrj  
       Nov 15, 2017
    grammar sugar
    记住好了。
    ssptool
        3
    ssptool  
       Nov 15, 2017
    func 作为函数指针,而*func 是函数,因此可以把(*func)()作为函数调用
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5762 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 06:58 · PVG 14:58 · LAX 23:58 · JFK 02:58
    ♥ Do have faith in what you're doing.