I have a function:
static int myprintf(const char* fmt, ...)
I want to know the size in bytes of all myprintf arguments if they were printed to the buffer. I need to distribute the array dynamically, to which I can print the arguments (using sprinfor _vsprinf) For example, on a 32-bit OS, for myprintf ("% d% c", 10, "a"); the size of the arguments to myprintf is 5.
I tried to implement it like this:
va_list ap;
va_start(ap, fmt);
myArgSize(ap);
Can anyone advise how to implement myArgSize.
I was told to try something like this
char c;
int len = ::_vsnprintf(&c, 1, fmt, ap);
It does not work because more than one byte is written. But there is probably some workaround.
thank
Yakov source
share