wohenyingyu01
V2EX  ›  问与答

c 语言如何能够实现无限多参数的函数(不用数组)?

  •  
  •   wohenyingyu01 · May 31, 2016 · 3189 views
    This topic created in 3825 days ago, the information mentioned may be changed or developed.
    类似 printf()这种可以无限加逗号的是怎么实现的?初学者,没有谷歌到答案。。。
    13 replies  •  2016-06-01 10:57:06 +08:00
    debiann
    debiann
    May 31, 2016 via iPhone❤️1
    1
    搜 不定参数函数
    LMkillme
    LMkillme
    May 31, 2016❤️1
    2
    可变参数列表
    am241
    am241
    May 31, 2016 via Android❤️1
    3
    stdarg.h
    dphdjy
    dphdjy
    May 31, 2016 via Android
    4


    麻烦回去重新学习如何正确使用 Google 及各种术语
    BGLL
    BGLL
    May 31, 2016
    5
    就 C 而言的话。关键词:可变参数
    类似:
    void printf(char *fmt, ...)
    {
    }
    wohenyingyu01
    wohenyingyu01
    OP
    May 31, 2016❤️1
    6
    @dphdjy 本身就不知道术语如何谷歌?我知道了术语还需要谷歌吗?
    theFool
    theFool
    May 31, 2016❤️1
    7
    @wohenyingyu01

    第二个, 点开就是了。

    问人问题态度还这样?
    tyfulcrum
    tyfulcrum
    May 31, 2016
    8
    楼主还是找本靠谱的书系统地看一遍吧,比如*Pointers on C*,比这么着东一榔头西一棒子要强不少。
    ffffwh
    ffffwh
    May 31, 2016
    9
    上 C++

    template <typename ... Args>
    void func(Args&& ... args /*大概吧*/) { }

    还是强类型的...
    just4test
    just4test
    May 31, 2016❤️2
    10
    @wohenyingyu01 我觉得你说的很对。

    @dphdjy 不知道术语谷歌也没用,知道术语百度也行。没必要这么大优越感。
    SoloCompany
    SoloCompany
    Jun 1, 2016
    11
    @just4test 从 7 楼的截图来看,你不是不知道怎么 google ,而是根本就没有进行过尝试,简称伸手党,而且还有欺骗成份
    wohenyingyu01
    wohenyingyu01
    OP
    Jun 1, 2016 via iPhone
    12
    @SoloCompany 我谷歌到的全是用数组。好的那我承认不会用谷歌,某些人就有优越感了吧?
    just4test
    just4test
    Jun 1, 2016❤️1
    13
    @SoloCompany 我在 google 和百度里尝试了 c 无限多参数 没有得到想要的结果。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2387 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 03:22 · PVG 11:22 · LAX 19:22 · JFK 22:22
    ♥ Do have faith in what you're doing.