Delphi syntax:procedure BinToHex(Buffer, Text: PChar; BufSize: Integer);C++ syntax:extern PACKAGE void __fastcall BinToHex(char *Buffer, char *Text, int BufSize);DescriptionCall BinToHex to convert the binary value in a buffer into a string that is its hexadecimal representation.Buffer is a buffer of bytes that contains the binary value.Text returns a null-terminated string that represents the value of Buffer as a hexadecimal number.BufSize is the size of Buffer. Text needs to point to a sequence of characters that has at least 2*BufSize bytes because each hexadecimal character represents two bytes.
楼上的怎么只说了要做什么,就没有具体的code出来吗? 新手我也想看看呢。
二进制转十进制 function binToDec(Value :string) : string; var str : String; int : Integer; i : integer; begin Str := UpperCase(Value); Int := 0; for i := 1 to Length(str) do Int := Int * 2+ ORD(str[i]) - 48; Result := IntToStr(Int); end;
修改一下: function binToDec(Value :string) : integer; var str : String; int : Integer; i : integer; begin Str := UpperCase(Value); result := 0; for i := 1 to Length(str) do result := result * 2+ ORD(str[i]) - 48; end;procedure TForm1.Button1Click(Sender: TObject); var s: string; begin s:= '1000000000001111'; showmessage(inttostr(bintodec(s))); end;
for i:=8 to 24 do
b[i-9]:=a[i]
新手我也想看看呢。
function binToDec(Value :string) : string;
var
str : String;
int : Integer;
i : integer;
begin
Str := UpperCase(Value);
Int := 0;
for i := 1 to Length(str) do
Int := Int * 2+ ORD(str[i]) - 48;
Result := IntToStr(Int);
end;
function binToDec(Value :string) : integer;
var
str : String;
int : Integer;
i : integer;
begin
Str := UpperCase(Value);
result := 0;
for i := 1 to Length(str) do
result := result * 2+ ORD(str[i]) - 48;
end;procedure TForm1.Button1Click(Sender: TObject);
var
s: string;
begin
s:= '1000000000001111';
showmessage(inttostr(bintodec(s)));
end;