May 14th, 2010, 05:14 AM
Problem with converting std::string to CString
I am experiencing a problem in converting std::string to CString, and I don't know why it occurs. I am not using MFC. I just included atlstr.h.
Here is the code I use:
string mpname = "SCCMDC.SCCM.COM";
cout << "sMPIP: " << sMPIP << endl;
printf("Printf: %s", sMPIP);
printf("Printf2: %s", &sMPIP);
cout returns something like this:
While the two printfs returns something like this:
I am not sure if the above is causing another error: adding two CStrings.
CString sNewloc = "something" + cString1 + " something " + cString2;
printf("new loc: %s", sNewloc);
Am I converting it wrong or am I just printing it wrong? Can anyone help me with this?
Last edited by LeanA; May 14th, 2010 at 05:36 AM.
Reason: Additional problem
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!