Microsoft Foundation Classes (mfc.hlp) (Table of Contents; Topic list)
CString::GetBufferSetLength
CString                                     Up Contents Index Back
──Microsoft Foundation Classes──────────────────────────────────────────────
 
  char* GetBufferSetLength( int nNewLength )
  throw( CMemoryException );
 
  Parameter    Description
 
  <nNewLength> The exact size of the CString character buffer in bytes.
 
  Remarks
 
  Returns a pointer to the internal character buffer for the CString
  object, truncating or growing its length if necessary to exactly match
  the length specified in <nNewLength>. The returned pointer to char is
  not const and thus allows direct modification of CString contents.
 
  If you use the pointer returned by GetBuffer to change the string
  contents, you must call ReleaseBuffer before using any other CString
  member functions.
 
  The address returned by GetBuffer is invalid after the call to
  ReleaseBuffer or any other CString operation.
 
  The buffer memory will be freed automatically when the CString object is
  destroyed.
 
  NOTE: If you keep track of the string length yourself, you need not
        append the terminating null byte. You must, however, specify the
        final string length when you release the buffer with
        ReleaseBuffer, or you can pass -1 for the length and ReleaseBuffer
        will perform a strlen on the buffer to determine its length.
 
  Return Value
 
  A char pointer to the object's (usually null-terminated) ASCII character
  buffer.
 
  See Also
 
  CString::GetBuffer, CString::ReleaseBuffer
 
 
                                     -♦-