sing Borland C++ Builder 2009.
In a custom class that is comparable to a String class (for the sake of this Q at least) I have a function, like so:
(edited a bit for this Q)
MyString &MyString::Sprintf(const wchar_t *Text, ...)
{
wchar_t ResultStr[1000] ;
va_list List ;
va_start (List, Text) ;
int cnt = vswprintf (ResultStr, Text, List ) ;
#ifdef _DEBUG
if (cnt >= (int)sizeof(ResultStr)) {throw (sizeof(ResultStr)) ;}
#endif
va_end (List) ;
my_internally_handled_string.assign(ResultStr) ;
return *this;
}
I would however like to adjust this function (or make another one) that only takes the variables as input, and uses the class' internally managed string as input Text
for the vswprintf()
function.
Something like this:
MyString &MyString::Sprintf(...)
{
const wchar_t *Text = my_internally_handled_string.c_str() ;
// ... Rest see above
This doesn't work however. vswprintf
throws an exception. (tested with a perfectly OK text in my_internally_handled_string)
I wonder if it is at all possible and/or what I need to do to make it work the way I envision it ?