_vscprintf equivalent on Android?

前端 未结 1 1085
孤街浪徒
孤街浪徒 2021-01-14 01:41

_vscprintf is not available on Android. Also vsprintf(NULL, fmt, ap) does not work (produces seg fault), so there seems to be no way of calculating

1条回答
  •  说谎
    说谎 (楼主)
    2021-01-14 02:13

    Section [7.19.6.13]—The vsprintf function—of the C99 Standard does not state that the output buffer may be NULL.

    You probably want to use vsnprintf:

    int len = vsnprintf(NULL, 0, fmt, ap)
    

    If the call is successful, the return value is the number of characters that would have been written if the buffer were large enough, excluding the NUL terminator. This is like _vscprintf, which also does not include the NUL terminator in its count.

    0 讨论(0)
提交回复
热议问题