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.

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to