Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

C/C++ API Documentation | 2025.2

# StrBuf::Append( const char * )

Append a null-terminated string to a `StrBuf`. The string is logically appended to the string pointed to by the `StrBuf`'s `buffer`.

Virtual? | No |
Class | `StrBuf` |
Arguments | `const char *buf` | pointer to the first byte of the null-terminated string
Returns | `void` |

## Notes

The `StrBuf`'s `length` is incremented by the number of bytes prior to the first null byte in the string.

If the memory for the `StrBuf`'s `buffer` is not large enough, new memory to contiguously contain the results of appending the null-terminated string is allocated. If new memory is allocated, the old memory is freed. Any memory allocated is separate from the memory for the string.

## Example

Copy

    int main( int argc, char **argv )
    {
        char chars[] = "zy";
        StrBuf sb;

        sb.Set( "xyz" );

        cout &lt;&lt; "sb.Text() prior to sb.Append( chars ) returns ";
        cout &lt;&lt; "\"" &lt;&lt; sb.Text() &lt;&lt; "\"\n";
        cout &lt;&lt; "sb.Length() prior to sb.Append( chars ) returns ";
        cout &lt;&lt; sb.Length() &lt;&lt; "\n\n";

        sb.Append( chars );   // append char * to StrBuf

        cout &lt;&lt; "sb.Text() after sb.Append( chars ) returns ";
        cout &lt;&lt; "\"" &lt;&lt; sb.Text() &lt;&lt; "\"\n";
        cout &lt;&lt; "sb.Length() after sb.Append( chars ) returns ";
        cout &lt;&lt; sb.Length() &lt;&lt; "\n";
    }

Executing the preceding code produces the following output:

Copy

    sb.Text() prior to sb.Append( chars ) returns "xyz"
    sb.Length() prior to sb.Append( chars ) returns 3

    sb.Text() after sb.Append( chars ) returns "xyzzy"
    sb.Length() after sb.Append( chars ) returns 5

Your search for returned results