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

C/C++ API Documentation | 2025.2

# StrBuf::Set( const char * )

Set a `StrBuf` from a null-terminated string.

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

## Notes

Initialize the `StrBuf` before calling `Set()`.

The `length` of the `StrBuf` is set to the number of bytes prior to the first null byte in the string.

Any memory allocated for the `StrBuf`'s `buffer` is separate from the memory for the string.

## Example

Copy

    #include &lt;iostream&gt;

    #include &lt;stdhdrs.h&gt;
    #include &lt;strbuf.h&gt;

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

        sb.Set( chars );   // set StrBuf from char *

        cout &lt;&lt; "chars[] = \"" &lt;&lt; chars &lt;&lt; "\"\n";
        cout &lt;&lt; "sb.Text() returns \"" &lt;&lt; sb.Text() &lt;&lt; "\"\n";
    }

Executing the preceding code produces the following output:

    chars[] = "string"
    sb.Text() returns "string"

Your search for returned results