_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
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.