i've looked around for quite a while now, but can't find any reasonable solution for this. i'm trying to write a function that takes variable arguements (i.e. has char * fmt and '...' as two of its parameters), finds out how many bytes the resulting string formed by the arguement list will be, allocates that many bytes, then calls vsprintf or a similar function to actually write the string.
it says on msdn that there is the _vscprintf function, which returns the number of bytes (which is exactly what i want), but my compiler (msvc 6.0) can't find the function even though i've included the headers it says to. in fact, a search for the text "_vscprintf" in all files under the "...\Visual Studio\" path comes up empty, so not only is it not defined anywhere in my libraries, the string '_vscprintf' does not appear anywhere in my libraries.
i also found during research that the vsnprintf function is supposed to take a byte count as the buffer size, and return the byte amount that would have been written if the buffer were large enough. so, u can call it once with a NULL buffer and 0 count, then call it again after allocating the return value of the first call. but, the implementation of this on my windows machine returns -1 if the string is not long enough (so, i cant use this function on windows for my purporses).
anyone know how to do this, preferablably as portable as possible although i'm fine with doing a [#ifdef WIN32 ... #else ... #endif] if there's no other way.
it says on msdn that there is the _vscprintf function, which returns the number of bytes (which is exactly what i want), but my compiler (msvc 6.0) can't find the function even though i've included the headers it says to. in fact, a search for the text "_vscprintf" in all files under the "...\Visual Studio\" path comes up empty, so not only is it not defined anywhere in my libraries, the string '_vscprintf' does not appear anywhere in my libraries.
i also found during research that the vsnprintf function is supposed to take a byte count as the buffer size, and return the byte amount that would have been written if the buffer were large enough. so, u can call it once with a NULL buffer and 0 count, then call it again after allocating the return value of the first call. but, the implementation of this on my windows machine returns -1 if the string is not long enough (so, i cant use this function on windows for my purporses).
anyone know how to do this, preferablably as portable as possible although i'm fine with doing a [#ifdef WIN32 ... #else ... #endif] if there's no other way.