returning a formated string

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I'm making a function that returns a formated String.
my best attempt is shown but it does not work.

I think it does not expand out the "args" when it is passed in.
is there a way to make CString::Format expand out the Arguments List?

p.s. if I should be using sprintf or something else like that, let me know also.

my DevEnv is MS VC++ 6

CString GetFormatedString(LPCTSTR fmt,...)
{
  va_list args;
  CString msg;

  va_start(args, fmt);
  msg.Format(fmt, args);
  va_end(args);
  return msg;
}

cheers and thanks
.



Relevant Pages

  • Re: passing a va_list to sprintf
    ... > sprintf(buf, format, args); ... > But I can't get sprintf to properly take the args I have given to f. ... What you want is vsprintf and not sprintf. ...
    (comp.lang.c)
  • [PATCH] vsprintf.c cleanups
    ... Make sprintf call vsnprintf directly ... int vsprintf(char *buf, const char *fmt, va_list args) ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • sprintf with dynamic number of elements
    ... I'm looking for a way to pass a dynamic number of args to sprintf. ... It seems like sprintf should support this natively, ... Is there a way to accomplish this? ...
    (comp.lang.php)
  • Re: passing a va_list to sprintf
    ... > void f ... > sprintf(buf, format, args); ... > But I can't get sprintf to properly take the args I have given to f. ...
    (comp.lang.c)