How to user CString.Format with CString?

Feb 18, 2013 at 9:19am
I have a two CString var with using MFC.
CString a = "abc";
CString b = "def";

And int c = 5;

I want to display "abc05def".

However, this code blow doesn't work.

a.Format("%s%02d%s", a, b, c)
and
a.Format("%s%02d%s", a.GetBuffer(0), b.GetBuffer(0), c)

Anyone know how??
Feb 18, 2013 at 9:23am
I forgot to cast (LPCTSTR). : P
Feb 19, 2013 at 2:10am
1
2
CString strC;
strC.Format("%s%02d%s", a, b, c);

you need a new CString var
Topic archived. No new replies allowed.