StrRef::Set( char * , int )
Set a StrRef
to reference an existing null-terminated
string.
Virtual? |
No |
|
Class |
||
Arguments |
|
the null-terminated string to reference |
|
the length of the string |
|
Returns |
|
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
#include <iostream> #include <stdhdrs.h> #include <strbuf.h> int main( int argc, char **argv ) { char chars[] = "xyzzy"; StrBuf sb; StrRef sr; sb.Set( chars ); sr.Set( chars, 3 ); printf( "chars[] = \"%s\"\n", chars ); printf( "sr.Text() returns \"%s\"\n", sr.Text() ); printf( "sb.Text() returns \"%s\"\n", sb.Text() ); return 0; }
Executing the preceding code produces the following output:
chars[] = "xyzzy" sr.Text() returns "xyzzy" sb.Text() returns "xyz"