M mynlxx Unregistered / Unconfirmed GUEST, unregistred user! 2002-07-06 #1 buf: array[0..2047] of char; s:String; 如何将s与buf合并?
D devil_li Unregistered / Unconfirmed GUEST, unregistred user! 2002-07-06 #3 var buf: array[0..2047] of char; s: string; C: array of Char; begin SetLength(C, Sizeof(buf) + Length(s)); Move(buf[Low(Buf)], C[Low(C)], Sizeof(buf)); Move(Pointer(s)^, C[Length(buf)], Length(s)); end; 测试通过
var buf: array[0..2047] of char; s: string; C: array of Char; begin SetLength(C, Sizeof(buf) + Length(s)); Move(buf[Low(Buf)], C[Low(C)], Sizeof(buf)); Move(Pointer(s)^, C[Length(buf)], Length(s)); end; 测试通过
张 张无忌 Unregistered / Unconfirmed GUEST, unregistred user! 2002-07-06 #4 zSchar; getmem(zS,length(s)+2048); FillChar(zS^,length(s)+2048,0) CopyMemory(zS,@buf,2048); inc(zS,2048); CopyMemory(zS,@s[1],length(s));
zSchar; getmem(zS,length(s)+2048); FillChar(zS^,length(s)+2048,0) CopyMemory(zS,@buf,2048); inc(zS,2048); CopyMemory(zS,@s[1],length(s));