Re: CString help



jp2code wrote:
Wow! Thanks gang! I had 27 occurrences of "GetBuffer(0)" in my code, and not one call to ReleaseBuffer.

That's fixed now, though.

I have a little Borland background. There, I had to use AnsiString (like std::string) and I accessed the data using AnsiString::c_str(). When I first started using VC, GetBuffer looked like Msft's equivalent. Wrong! :)

I don't know Borland, but I would imagine that AnsiString::c_str() returns const char*. CString::GetBuffer() returns char* (in ANSI build), a string whose contents you can modify.

CString::GetBuffer() can increase efficiency in some situations, but is best avoided, IMHO. You will notice that std::string has no such mechanism.

--
David Wilkinson
Visual C++ MVP
.