Re: CString help



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! :)

"Ajay Kalra" wrote:

Why use GetBuffer here? You dont need it. Just pass the CString.
Operator LPCTSTR will take care of the rest.

Also, you must call ReleaseBuffer after calling GetBuffer:
http://msdn2.microsoft.com/en-us/library/ms928943.aspx

---
Ajay




.



Relevant Pages

  • Re: GetBuffer Problem
    ... ReleaseBuffer methods inside a recursive part of the software. ... Note that once GetBuffer is called, the string is in an indeterminate state and cannot ... depending on the length of the strings and the depth of recursion. ... I'm not allocating too much memory at once, ...
    (microsoft.public.vc.mfc)
  • Re: CString::Getbuffer und Releasebuffer
    ... > Ehrlich gesagt habe ich nicht genau kapiert was bei Get- und ReleaseBuffer ... Der cast-operator liefert einfach den Zeiger. ... den CString verändern will. ... Ich habe nicht ausprobiert, was passiert, wenn man zwischen GetBuffer ...
    (microsoft.public.de.vc)
  • Re: LPWCH und CString
    ... Aber der Tip mit dem GetBuffer() und ... ReleaseBuffer() ... Damit kriege ich den Zeiger und alles läuft bestens. ...
    (microsoft.public.de.vc)
  • Re: Another issue in my MFC app
    ... it doesn't hurt to call ReleaseBuffer() so there is no reason not to call it. ... "Joseph M. Newcomer" wrote in message ... Note that if you call GetBuffer, you must call ReleaseBuffer, e.g., ...
    (microsoft.public.vc.mfc)