Pointer to string conversion?

I allocate memory using GetMem (1028 bytes long), so I have a dedicated pointer.

Then I read the contents, and I know that there is, for example, 1028 bytes read. how can i cast a pointer or convert it to a string?

Should I ignore memory contents before conversion?

Thank!

+5
source share
1 answer

Use SetString. Pass it a string variable, a pointer, and the length of the string (1028). Delphi lines implicitly terminate to zero, so the function will automatically add this function (even if your buffer already has zero bytes).

, . , , 1028 , .

+8

All Articles