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

#include <iostream>

#include <stdhdrs.h>
#include <strbuf.h>

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

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

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

Executing the preceding code produces the following output:

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