2.2.3.15.12 string::GetBufferSetLength

Description

Retrieve a pointer to the internal character buffer for the string, if necessary, truncate or grow its length to exactly match the length specified by nNewLength.

Syntax

char * GetBufferSetLength( int nNewLength )

Parameters

nNewLength
[input]Specify the exact size of the string character buffer in characters.

Return

This is an LPTSTR pointer to the character buffer of the null-terminated object.

Examples

EX1

void string_GetBufferSetLength_ex1()
{
    string str( "abcdef" );
    char* pstr = str.GetBufferSetLength(3);
    pstr[0] = 'A';
    out_str(str);        //output should be "Abc"
}

Remark

If you use the pointer returned by GetBufferSetLength to change the string contents, you may need to call ReleaseBuffer before using any other string member methods.

See Also

string::GetBuffer

Header to Include

origin.h