数组操作!谢谢
id是一个整型数,把id转换为字节数组,注意低字节在前。
str是字符窜型,把str转换为字节数组,
接着两个数组连接在一起,
最后显示出字符窜。
[解决办法]
你自己再修改吧
- Delphi(Pascal) code
function inttoBin(i,len: integer): string; begin while i <> 0 do begin //i mod 2取模,再使用format格式化 result := Format('%d' + result, [i mod 2]); i := i div 2 end ; while length(Result)<len do Result:='0'+Result; end;var int, i: Integer; intbytes: array[0..3] of Byte; str: string; strbytes: array of Char;begin int := 123456789; Move(int, intbytes, 4); Memo1.Lines.Add(inttoBin(intbytes[3],8)); Memo1.Lines.Add(inttoBin(intbytes[2],8)); Memo1.Lines.Add(inttoBin(intbytes[1],8)); Memo1.Lines.Add(inttoBin(intbytes[0],8)); Memo1.Lines.Add(inttoBin(intbytes[3],8) + inttoBin(intbytes[2],8) + inttoBin(intbytes[1],8) + inttoBin(intbytes[0],8)); str := 'ABCDEFGhijk'; SetLength(strbytes, Length(str)); for i := 1 to Length(str) do begin strbytes[i - 1] := str[i]; Memo1.Lines.Add(strbytes[i - 1]); end;end;
[解决办法]
http://zhidao.baidu.com/question/198194265.html
[解决办法]
- Delphi(Pascal) code
const id=12345678;const str='ABCDEFGH';var i:integer; Arr1,Arr2:array of Byte;begin setlength(Arr1,Length(inttostr(id))); setlength(Arr2,Length(str)); move(Pchar(inttostr(id))^,arr1[0],Length(inttostr(id))); move(Pchar(str)^,arr2[0],Length(str));{两个数组怎么连接自己处理 for i:=low(arr1) to high(arr1) do memo1.Lines.Add(chr(arr1[i])); for i:=low(arr2) to high(arr2) do memo1.Lines.Add(chr(arr2[i]));}end;
[解决办法]
这......
前面有ID转换过来4个字节,加上这40字节转换成的20个字节,一共24字节,
而你的
"? ?+F"L?N`_?4" 只有16个字节,怎么回事?