Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

string vs CString 1

Status
Not open for further replies.

javaguy1

Programmer
Joined
May 14, 2003
Messages
136
Location
US
i no sooner learn about standard library class string than i find there is also a CString. can someone tell me how they are different?
 
CString is part of the MFC library and therefore not portable. Other than that they also differ in their implementations and functionality. You can see the differences by looking at their APIs.

-pete
 
not portable is enough answer for me. string seems to be pretty good. i dont see why i would need CString then
 
CString has mainly 3 benefits (as I see it):

1) It works with both Unicode and ASCII.

2) It supports loading strings from the resources.

3) It has a const char* operator (LPCTSTR). (no big deal, string has its c_str(), but I find the operator slightly more convenient)

For me portability isn't an issue, I find the Windows-based market big enough.


/Per
Nerdy signatures are as lame as the inconsistent stardates of STTNG.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top