CString::Format()
-
visual C++ how to add a formatted CString value to the original value, e.g: how to achieve these logical statements?! CString str; str += str.Format(" qer23 %d asdgsgd", var); :omg:
str.Format(...)
doesn't return a string, it reassigns tostr
in-place. You'll need to use a second variable for theFormat()
call and append that tostr
. --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Pinky, are you pondering what I'm pondering? I think so Brain, but how will we fit the hamster inside the accordion? -
visual C++ how to add a formatted CString value to the original value, e.g: how to achieve these logical statements?! CString str; str += str.Format(" qer23 %d asdgsgd", var); :omg:
-
visual C++ how to add a formatted CString value to the original value, e.g: how to achieve these logical statements?! CString str; str += str.Format(" qer23 %d asdgsgd", var); :omg:
or str.Format("%s qer23 %d asdfgsf",str,var);
MSN Messenger. prakashnadar@msn.com "If history isn't good, just burn it." - Sidhuism.
-
or str.Format("%s qer23 %d asdfgsf",str,var);
MSN Messenger. prakashnadar@msn.com "If history isn't good, just burn it." - Sidhuism.
This approach won't work. To quote from the MSDN documentation for CString::Format() The call will fail if the string object itself is offered as a parameter to Format. For example, the following code: CString str = "Some Data"; str.Format("%s%d", str, 123); // Attention: str is also used in the parameter list. will cause unpredictable results.
-
This approach won't work. To quote from the MSDN documentation for CString::Format() The call will fail if the string object itself is offered as a parameter to Format. For example, the following code: CString str = "Some Data"; str.Format("%s%d", str, 123); // Attention: str is also used in the parameter list. will cause unpredictable results.
yeah sounds logical, coz its working on the same object, i assumed that a copy of the parameter would be made.
MSN Messenger. prakashnadar@msn.com "If history isn't good, just burn it." - Sidhuism.
-
visual C++ how to add a formatted CString value to the original value, e.g: how to achieve these logical statements?! CString str; str += str.Format(" qer23 %d asdgsgd", var); :omg:
If you are using VS.NET 2002 or later, the
CString
class includes the member functionAppendFormat
, which does what you are asking. If you are using VC6, you will need to do something like this:CString str,tmp;
str = ";kj;lak;sajlg";
tmp.Format(" qer23 %d asdgsgd", var);
str += tmp;
Software Zen:
delete this;