交流一下,
我一般用treader的readchar方法.
得出一个char c然后
var
c:char;
m,i:integer;
begin
m:=ord(c);
m:=2;
edit1.text:='';
for i:=1 to 8 do
begin
edit1.text:=chr((ord('0')+(m mod 2)))+edit1.text;
m:= m shr 1;
end;
可以这样:
function inttobin(value:longint:string;
var
i: integer;
begin
result:='';
for i:=8 downto 0 do begin
if value and (1 shl i)<>0 then begin
result:=result+'1';
end else begin
result:=result+'0';
end;
end;
end;
...
f:file of char;
c:char;
i:integer;
begin
assignfile(f,'abc.efg');
reset(f);
for i:=1 to filesize(f) do
begin
read(f,c);
memo1.lines.add(inttobin(ord(c))+' ');
end;
closefile(f);
end;
...