在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
MoveMemory、CopyMemory 的功能类似, 都是复制内存, 都是调用 Move 过程;
{例1} var buf1,buf2: array[0..9] of AnsiChar; begin buf1 := '0123456789'; buf2 := 'abcdefghij'; Move(buf2[2], buf1[4], 5); ShowMessage(buf1); {0123cdefg9} ShowMessage(buf2); {abcdefghij} end; {例2} var buf1,buf2: array[0..9] of AnsiChar; begin buf1 := '0123456789'; buf2 := 'abcdefghij'; CopyMemory(@buf2[2], @buf1[4], 5); ShowMessage(buf1); {0123456789} ShowMessage(buf2); {ab45678hij} end; {例3} var s1,s2: TStringStream; {两个字符串流} begin s1 := TStringStream.Create; s2 := TStringStream.Create; {向第一个字符串流写入} s1.WriteString('万一的 Delphi 博客'); ShowMessage(s1.DataString); {万一的 Delphi 博客} {设置第二个字符串流的大小} s2.SetSize(6); {从第一个流复制到第二个流} CopyMemory(s2.Memory, s1.Memory, s2.Size); ShowMessage(s2.DataString); {万一的} s1.Free; s2.Free; end;
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论