StrBuf::Clear()
Clear the length
member of a StrBuf
.
Virtual? |
No |
|
Class |
||
Arguments |
None |
|
Returns |
|
Notes
Only the length
member of the StrBuf
is
zeroed.
To set the buffer
member to a zero-length string, call Terminate()
after calling
Clear()
.
See also
Example
#include <iostream> #include <stdhdrs.h> #include <strbuf.h> int main( int argc, char **argv ) { StrBuf sb; sb.Set( "xyz" ); cout << "Prior to sb.Clear() and sb.Terminate():\n"; cout << " sb.Length() returns " << sb.Length() << "\n"; cout << " sb.Text() returns \"" << sb.Text() << "\"\n\n"; sb.Clear(); // zero out the length cout << "After sb.Clear() but prior to sb.Terminate():\n"; cout << " sb.Length() returns " << sb.Length() << "\n"; cout << " sb.Text() returns \"" << sb.Text() << "\"\n\n"; sb.Terminate(); cout << "After sb.Clear() and sb.Terminate():\n"; cout << " sb.Length() returns " << sb.Length() << "\n"; cout << " sb.Text() returns \"" << sb.Text() << "\"\n"; }
Executing the preceding code produces the following output:
Prior to sb.Clear() and sb.Terminate(): sb.Length() returns 3 sb.Text() returns "xyz" After sb.Clear() but prior to sb.Terminate(): sb.Length() returns 0 sb.Text() returns "xyz" After sb.Clear() and sb.Terminate(): sb.Length() returns 0 sb.Text() returns ""