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

C/C++ API Documentation | 2026.1

# StrRef::Set( char * )

Set a `StrRef` to reference an existing null-terminated string.

Virtual? | No |
Class | `StrRef` |
Arguments | `char *buf` | the null-terminated string to reference
Returns | `void` |

## Notes

`StrRef::Set()` does not copy the target string; it simply establishes a pointer to it. Be sure that the `StrRef` pointing to the target string does not outlive the target 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[] = "xyz";
        StrRef sr;

        sr.Set( chars );

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

Executing the preceding code produces the following output:

    chars[] = "xyz"
    sr.Text() returns "xyz"

Your search for returned results