printf and casting float arguments

前端 未结 2 713
面向向阳花
面向向阳花 2021-01-21 03:52

As a part of my program I use:

int ret = vprintf (format, args);

The args I get on the stack and I can\'t know what actually was

2条回答
  •  情深已故
    2021-01-21 04:21

    There's no easy, portable way to do this; to inspect a va_list, you must know what types of values it holds and the only way to know is by parsing the format string. Effectively, you'll have to reimplement part of vprintf. (Part, because you can still send off the individual format specifier + cast value pairs to printf and not worry about how to pick apart a float.)

提交回复
热议问题