A function returns a pointer and a length (via the arguments) from an unknown DLL.
Result = SpamnEggs( &pBytes, &nBytes )
The pointer points to a valid memory address at which are nBytes sequential bytes.
These bytes contain valid ascci values for text. There is no null termination!
I am tasked with “ovelaying” a string type of some sort in as few simple operations in generic C++ code (without complex libraries or using byte) before output:
cout << sresult
Added:
without copying the bytes as this is a large buffer that must be traversed.
Prototype:
int SpamnEggs( void* pBytes, void* nBytes );
becomes
int SpamnEggs( char** pBytes, int* nBytes );
Many thanks all. Great answers and all very valid.
You can just construct a std::string from the pointer and a length.
(assuming
pBytesis achar*pointer, otherwise you need a small cast).