<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
I believe pchar has special treatment where pchar[i] is the same as pchar^[i]<br>
<br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
do move(Hello^, ...<span id="ms-outlook-android-cursor"></span><br>
<br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
<span id="OutlookSignature">
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
--<br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
Alexander Grotewohl<br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
<a href="https://dcclost.com">https://dcclost.com</a></div>
</span><br>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> fpc-pascal <fpc-pascal-bounces@lists.freepascal.org> on behalf of Giuliano Colla <giuliano.colla@fastwebnet.it><br>
<b>Sent:</b> Tuesday, May 19, 2020 1:05:54 PM<br>
<b>To:</b> FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org><br>
<b>Subject:</b> [fpc-pascal] Copying a Pchar to an array of bytes</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">I'm not too familiar with Pchar, and apparently I'm missing something.<br>
<br>
I have a Pchar string which I must copy into an array of bytes.<br>
<br>
Could someone explain me while a move doesn't work while an assignment <br>
byte by byte does?<br>
<br>
Here's a snippet of the code:<br>
<br>
buffer: array [0..1023] of byte;<br>
Hello: PChar = 'Hello from server';<br>
....<br>
len := strlen(Hello);<br>
----<br>
Move(Hello,buffer,len); <--- Garbage in buffer - doesn't work<br>
----<br>
for I := 0 to Pred(len) do<br>
begin<br>
buffer[I] := Byte(Hello[I]); <---- Works just fine.<br>
end;<br>
<br>
I fail to understand why. What I'm missing?<br>
<br>
Giuliano<br>
<br>
-- <br>
Do not do to others as you would have them do to you.They might have different tastes.<br>
<br>
_______________________________________________<br>
fpc-pascal maillist - fpc-pascal@lists.freepascal.org<br>
<a href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a><br>
</div>
</span></font></div>
</body>
</html>