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

Re: returning a formated string by Igor

Igor
Fri Aug 19 12:21:16 CDT 2005

hswerdfe <hswerdfe@example.com> wrote:
> 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?

You need CString::FormatV
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925



Re: returning a formated string by Doug

Doug
Fri Aug 19 12:20:50 CDT 2005

On Fri, 19 Aug 2005 13:23:07 -0400, hswerdfe <hswerdfe@example.com> wrote:

>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

Use CString::FormatV.

--
Doug Harrison
VC++ MVP