qbytearray find two similar values
-
hi i have data like this
"8800010026020000086A54161565415621" + some another data + "8800010026020000083A352303661445"
i want to find the two index start with "8800010026020000"QFile file("somthing"); file.open(QIODevice::ReadOnly); QByteArray data = file.readAll(); file.close(); QByteArray patch_data1 = QByteArray::fromHex("8800010026020000"); int64_t index = data.indexOf(patch_data1); qInfo() <<data.mid(index,16).toHex(); -
hi i have data like this
"8800010026020000086A54161565415621" + some another data + "8800010026020000083A352303661445"
i want to find the two index start with "8800010026020000"QFile file("somthing"); file.open(QIODevice::ReadOnly); QByteArray data = file.readAll(); file.close(); QByteArray patch_data1 = QByteArray::fromHex("8800010026020000"); int64_t index = data.indexOf(patch_data1); qInfo() <<data.mid(index,16).toHex(); -
@JonB
that's it thanks a lot
the problem is solved and this is the new codeQFile file("test.qcn"); file.open(QIODevice::ReadOnly); QByteArray data = file.readAll(); file.close(); QByteArray patch_data1 = QByteArray::fromHex("8800010026020000"); int64_t index = data.indexOf(patch_data1); int64_t index2 = data.indexOf(patch_data1,index+patch_data1.size()); qInfo() <<data.mid(index,17).toHex()<<index<< data.mid(index2,17).toHex() << index2;