-
May 14th, 2010, 04:14 AM
#1
Problem with converting std::string to CString
Hi all,
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";
CString sMPIP(mpname.c_str());
cout << "sMPIP: " << sMPIP << endl;
printf("Printf: %s", sMPIP);
printf("Printf2: %s", &sMPIP);
cout returns something like this:
sMPIP: 000000000003046F8
While the two printfs returns something like this:
Printf: <
Printf: H=1
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?
Thank you!
Last edited by LeanA; May 14th, 2010 at 04:36 AM.
Reason: Additional problem
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|