beautypg.com

HP Integrity NonStop J-Series User Manual

Page 61

background image

cout << b.length(); // Prints "3"
cout << strlen(b.data()); // Prints "3"

cout << c.length(); // Prints "7"
cout << strlen(c.data()); // Prints "3"
return 0; }

You will notice that two different constructors are used above. The constructor in lines 1 and 2
takes a single argument of const char*, a null-terminated string. Because it takes a single
argument, it may be used in type conversion (ARM 12.3.1). The length of the results is
determined the usual way, by the number of bytes before the null. The constructor in line 3 takes
a const char* and a run length. The constructor will copy this many bytes, including any
embedded nulls
.

The length of an

RWCString

in bytes is always given by RWCString::length(). Because the

string may include embedded nulls, this length may not match the results given by strlen().

Remember that indexing and other operators_basically, all functions using an argument of type
size_t_work in bytes. Hence, these operators will not work for

RWCString

s containing multibyte

strings.

This manual is related to the following products: