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

后端 未结 5 617
遇见更好的自我
遇见更好的自我 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 16:00

    You must indicate the number of parameters somehow (if you're writing portable code) when using variable length argument lists. You may be now thinking "But printf doesn't require you to indicate a number of arguments!"

    True, however the number can be inferred by first parsing the format strings for % format specifiers.

提交回复
热议问题