[fpc-pascal] Copying a Pchar to an array of bytes
Giuliano Colla
giuliano.colla at fastwebnet.it
Tue May 19 19:05:54 CEST 2020
I'm not too familiar with Pchar, and apparently I'm missing something.
I have a Pchar string which I must copy into an array of bytes.
Could someone explain me while a move doesn't work while an assignment
byte by byte does?
Here's a snippet of the code:
buffer: array [0..1023] of byte;
Hello: PChar = 'Hello from server';
....
len := strlen(Hello);
----
Move(Hello,buffer,len); <--- Garbage in buffer - doesn't work
----
for I := 0 to Pred(len) do
begin
buffer[I] := Byte(Hello[I]); <---- Works just fine.
end;
I fail to understand why. What I'm missing?
Giuliano
--
Do not do to others as you would have them do to you.They might have different tastes.
More information about the fpc-pascal
mailing list