Solved How to write in to QVector?
-
WINAPI function ReadProcessMemory if succeeds write the result in to users single variable or an array, like this:
char *tempByte = new char[memInfo.RegionSize]; size_t ssss; ReadProcessMemory(currHandle, (LPVOID)addr, tempByte, memInfo.RegionSize, &ssss);
Dynamic array of my chars is filled with correct data. Why i can't do the same with vectors, why only with default C++ array? Here is analog, it compiles, but crash program when i run it:
QVector<char> tempByte; tempByte.resize(memInfo.RegionSize); size_t ssss; ReadProcessMemory(currHandle, (LPVOID)addr, &tempByte, memInfo.RegionSize, &ssss);
-
@Engelard Have your tried QVector::data()?
"This function is mostly useful to pass a vector to a function that accepts a plain C++ array."
Regards
-
Small side note, for this cases you normally would use
QByteArray
rather thanQVector<char>
-
-
Plus, i need to use that data in qSort and qBindariFind, it require array of int values, not raw bytes.
One thing. If you have some data which is an array of bytes or chars or a
QByteArray
from what you've been saying, and you now say you intend to use that data for sorts/finds "which require ints not bytes", it's strange data that you can treat as bytes or ints. Not impossible, but...?