You can't. You have to manage for the caller to indicate the number of arguments somehow. You can:
Pass the number of arguments as the first variable
Require the last variable argument to be null, zero or whatever
Have the first argument describe what is expected (eg. the printf format string dictates what arguments should follow)
How to count the number of arguments passed to a function that accepts a variable number of argument
管理调用参数
最新推荐文章于 2025-12-04 16:38:42 发布
本文探讨了在不指定参数数量的情况下管理函数调用的方法,包括传递参数数量作为第一个变量、使用特殊值标记最后一个可变参数及利用首个参数描述预期参数等技巧。
1万+

被折叠的 条评论
为什么被折叠?



