var P1, P2 : PChar; A : array[0..4] of Char; begin FillChar(A, 5, 97 ); A[4] := #0; //A==['a','a','a','a','\0'] P1 := @A; move(P1, P2, 5); showmessage(strpas(p2)); //'aaaa\0' end;
var P : PChar; A : array of Char; begin SetLength(A, 5); P := PChar('abcde'); move(P, A, 5); showmessage(A[0]+A[1]+A[2]+A[3]+A[4]); end;
var B : array[0..3] of Byte; begin B[0]:=65; B[1]:=66; B[2]:=67; B[3]:=68; showmessage(Chr(B[0])+Chr(B[1])+Chr(B[2])+Chr(B[3]));//'ABCD' move(B[0], B[1], 3); showmessage(Chr(B[0])+Chr(B[1])+Chr(B[2])+Chr(B[3]));//'AABC' end;Move(From, To, 复制的内存字节数);上面的例子,如果用Integer,不用Byte:var B : array[0..3] of Integer; begin B[0]:=65; B[1]:=66; B[2]:=67; B[3]:=68; showmessage(IntToStr(B[0])+IntToStr(B[1])+IntToStr(B[2])+IntToStr(B[3])); move(B[0], B[1], 3*4);//一个Integer占4个字节,所以,要*4 showmessage(IntToStr(B[0])+IntToStr(B[1])+IntToStr(B[2])+IntToStr(B[3])); end;
Copies bytes from a source to a destination.UnitSystemCategorymiscellaneous routinesprocedure Move(const Source; var Dest; Count: Integer);DescriptionMove copies Count bytes from Source to Dest. No range checking is performed. Move compensates for overlaps between the source and destination blocks. Whenever possible, use SizeOf to determine the count.
P1, P2 : PChar;
A : array[0..4] of Char;
begin
FillChar(A, 5, 97 ); A[4] := #0; //A==['a','a','a','a','\0']
P1 := @A;
move(P1, P2, 5);
showmessage(strpas(p2)); //'aaaa\0'
end;
P : PChar;
A : array of Char;
begin
SetLength(A, 5);
P := PChar('abcde');
move(P, A, 5);
showmessage(A[0]+A[1]+A[2]+A[3]+A[4]);
end;
B : array[0..3] of Byte;
begin
B[0]:=65; B[1]:=66; B[2]:=67; B[3]:=68;
showmessage(Chr(B[0])+Chr(B[1])+Chr(B[2])+Chr(B[3]));//'ABCD'
move(B[0], B[1], 3);
showmessage(Chr(B[0])+Chr(B[1])+Chr(B[2])+Chr(B[3]));//'AABC'
end;Move(From, To, 复制的内存字节数);上面的例子,如果用Integer,不用Byte:var
B : array[0..3] of Integer;
begin
B[0]:=65; B[1]:=66; B[2]:=67; B[3]:=68;
showmessage(IntToStr(B[0])+IntToStr(B[1])+IntToStr(B[2])+IntToStr(B[3]));
move(B[0], B[1], 3*4);//一个Integer占4个字节,所以,要*4
showmessage(IntToStr(B[0])+IntToStr(B[1])+IntToStr(B[2])+IntToStr(B[3]));
end;
你想用move来做什么?