Passing variable number of arguments around

前端 未结 11 633
我寻月下人不归
我寻月下人不归 2020-11-22 07:16

Say I have a C function which takes a variable number of arguments: How can I call another function which expects a variable number of arguments from inside of it, passing a

11条回答
  •  名媛妹妹
    2020-11-22 07:25

    There's no way of calling (eg) printf without knowing how many arguments you're passing to it, unless you want to get into naughty and non-portable tricks.

    The generally used solution is to always provide an alternate form of vararg functions, so printf has vprintf which takes a va_list in place of the .... The ... versions are just wrappers around the va_list versions.

提交回复
热议问题