How to loop through a va_list if the number of arguments is unknown?

后端 未结 5 621
遇见更好的自我
遇见更好的自我 2021-02-13 14:57

How do I loop through a va_list if the number of additional arguments is unknown?

#include 
#include 

int add(int x, int y, ...         


        
5条回答
  •  生来不讨喜
    2021-02-13 15:47

    The two answers above that suggest adding a first argument to indicate the number of arguments miss the point: the number of arguments is unknown.

    Using a sentinel value (or series of sentinel values) at the end is the only way to solve the problem.

提交回复
热议问题