algas
V2EX  ›  C

C 函数指针调用格式

  •  
  •   algas · Nov 15, 2017 · 3156 views
    This topic created in 3160 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   ·   1056 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 18:43 · PVG 02:43 · LAX 11:43 · JFK 14:43
    ♥ Do have faith in what you're doing.