Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
QByteArrayたとえば、この配列に含まれる「*」の数QByteArrayを知りたいとします。
QByteArray
QByteArray ドキュメントから:
int QByteArray::count ( const char * str ) const This is an overloaded function. Returns the number of (potentially overlapping) occurrences of string str in the byte array.
数えます。
QByteArray::indexOf(char ch, int from = 0) constループ内で使用できます。
QByteArray::indexOf(char ch, int from = 0) const
多分これ:
int i = 0, counter = 0; while((i = array.indexOf("*", i)) >= 0) counter++;