Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

BeginReading

« XPCOM API Reference

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 nsACString& str, char c)
  {
    const char* start = str.BeginReading();
    const char* end = str.EndReading();

    PRUint32 count = 0;
    while (start != end)
    {
      if (*start++ == c)
        ++count;
    }

    return count;
  }

See Also

Length, EndReading

Document Tags and Contributors

 Contributors to this page: Sheppy, Pmash
 Last updated by: Sheppy,