Summary
The BeginReading function returns a const pointer to the first element of the string's internal buffer.
const char_type* BeginReading() const;
Remarks
The resulting character array is not necessarily null-terminated. The length of the array is determined by the result of the Length method.
Example Code
// count the number of times a particular character appears in the string
PRUint32 CountChar(const nsAString& str, PRUnichar c)
{
const PRUnichar* start = str.BeginReading();
const PRUnichar* end = str.EndReading();
PRUint32 count = 0;
while (start != end)
{
if (*start++ == c)
++count;
}
return count;
}
