关于函数的参数传递?非常急?在线等 (50分)

  • 主题发起人 主题发起人 sunnysheng
  • 开始时间 开始时间
S

sunnysheng

Unregistered / Unconfirmed
GUEST, unregistred user!
function xor_xor(data1,data2,data:array of Char):integer;<br>var<br>&nbsp; tmp,tmp1,tmp2:array [0..8] of byte;<br>&nbsp; //data1,data2,data3:array [0..8] of Char;<br>&nbsp; i:integer;<br>&nbsp; str:string;<br>begin<br>&nbsp; str := '';<br>&nbsp; FillChar(tmp1,SizeOf(tmp1),$0);<br>&nbsp; FillChar(tmp2,SizeOf(tmp2),$0);<br>&nbsp; FillChar(tmp,SizeOf(tmp),$0);<br><br>&nbsp; tmp1[0]:= StrToInt('$'+data1[0]+data1[1]);<br>&nbsp; tmp1[1]:= StrToInt('$'+data1[2]+data1[3]);<br>&nbsp; tmp1[2]:= StrToInt('$'+data1[4]+data1[5]);<br>&nbsp; tmp1[3]:= StrToInt('$'+data1[6]+data1[7]);<br>&nbsp; tmp1[4]:= StrToInt('$'+data1[8]+data1[9]);<br>&nbsp; tmp1[5]:= StrToInt('$'+data1[10]+data1[11]);<br>&nbsp; tmp1[6]:= StrToInt('$'+data1[12]+data1[13]);<br>&nbsp; tmp1[7]:= StrToInt('$'+data1[14]+data1[15]);<br><br>&nbsp; tmp2[0]:= StrToInt('$'+data2[0]+data2[1]);<br>&nbsp; tmp2[1]:= StrToInt('$'+data2[2]+data2[3]);<br>&nbsp; tmp2[2]:= StrToInt('$'+data2[4]+data2[5]);<br>&nbsp; tmp2[3]:= StrToInt('$'+data2[6]+data2[7]);<br>&nbsp; tmp2[4]:= StrToInt('$'+data2[8]+data2[9]);<br>&nbsp; tmp2[5]:= StrToInt('$'+data2[10]+data2[11]);<br>&nbsp; tmp2[6]:= StrToInt('$'+data2[12]+data2[13]);<br>&nbsp; tmp2[7]:= StrToInt('$'+data2[14]+data2[15]);<br><br>&nbsp; for i:= 0 to 7 do<br>&nbsp; begin<br>&nbsp; &nbsp; tmp:= tmp1 xor tmp2;<br>&nbsp; &nbsp; str:= str + IntToHex(tmp,2);<br>&nbsp; end;<br>&nbsp; StrCopy(data,PChar(str));<br>&nbsp; Result:=1;<br><br>end;<br>变量为:<br>tmp_data:array [0..8] of Char;<br>d1,d2,d3: array [ 0.. 8]of Char;<br>tmp_data里的值为:'12345678'<br>d1里的值为:'12345678'<br>请问我这个tmp_data,d1里的值怎么传不进啊<br>xor_xor(tmp_data,d1,d2);<br>
 
It's OK.<br><br>function xor_xor(data1,data2: array of char; var data:array of Char):integer;<br>var<br>&nbsp;tmp,tmp1,tmp2:array [0..8] of byte;<br>&nbsp;//data1,data2,data3:array [0..8] of Char;<br>&nbsp;i:integer;<br>&nbsp;str:string;<br>begin<br>&nbsp;str := '';<br>&nbsp;FillChar(tmp1,SizeOf(tmp1),$0);<br>&nbsp;FillChar(tmp2,SizeOf(tmp2),$0);<br>&nbsp;FillChar(tmp,SizeOf(tmp),$0);<br><br>&nbsp;tmp1[0]:= StrToInt('$'+data1[0]+data1[1]);<br>&nbsp;tmp1[1]:= StrToInt('$'+data1[2]+data1[3]);<br>&nbsp;tmp1[2]:= StrToInt('$'+data1[4]+data1[5]);<br>&nbsp;tmp1[3]:= StrToInt('$'+data1[6]+data1[7]);<br>&nbsp;tmp1[4]:= StrToInt('$'+data1[8]+data1[9]);<br>&nbsp;tmp1[5]:= StrToInt('$'+data1[10]+data1[11]);<br>&nbsp;tmp1[6]:= StrToInt('$'+data1[12]+data1[13]);<br>&nbsp;tmp1[7]:= StrToInt('$'+data1[14]+data1[15]);<br><br>&nbsp;tmp2[0]:= StrToInt('$'+data2[0]+data2[1]);<br>&nbsp;tmp2[1]:= StrToInt('$'+data2[2]+data2[3]);<br>&nbsp;tmp2[2]:= StrToInt('$'+data2[4]+data2[5]);<br>&nbsp;tmp2[3]:= StrToInt('$'+data2[6]+data2[7]);<br>&nbsp;tmp2[4]:= StrToInt('$'+data2[8]+data2[9]);<br>&nbsp;tmp2[5]:= StrToInt('$'+data2[10]+data2[11]);<br>&nbsp;tmp2[6]:= StrToInt('$'+data2[12]+data2[13]);<br>&nbsp;tmp2[7]:= StrToInt('$'+data2[14]+data2[15]);<br><br>&nbsp;for i:= 0 to 7 do<br>&nbsp;begin<br>&nbsp; &nbsp;tmp:= tmp1 xor tmp2;<br>&nbsp; &nbsp;str:= str + IntToHex(tmp,2);<br>&nbsp;end;<br>&nbsp;StrCopy(data,PChar(str));<br>&nbsp;Result:=1;<br><br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>var<br>&nbsp; A, B, C: array[0..15] of Char;<br>begin<br>&nbsp; A := '1234567812345678';<br>&nbsp; B := '2134567812345678';<br>&nbsp; xor_xor(A, B, C);<br>&nbsp; ShowMessage(C);<br>end;
 
不行,执行到<br>tmp1[0]:= StrToInt('$'+data1[0]+data1[1]);时data1里面就是空的了啊
 
接受答案了.
 

Similar threads

S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
922
SUNSTONE的Delphi笔记
S
I
回复
0
查看
738
import
I
后退
顶部