16,747
社区成员




var
strm : TStringStream;
s : string;
begin
strm := TStringStream.Create;
try
strm.WriteString('1ab3c'); //写入字符串
strm.Position := 0; //设定读取位置
s := strm.ReadString(1); //参数为读取的长度
//s为读取的结果, lz根据情况作类型转换即可
finally
strm.Free;
end;
end;
var
strm : TStringStream;
s : string;
begin
strm := TStringStream.Create;
try
strm.WriteString('1ab3c');
strm.Position := 0;
// strm.Position := 3;
s := strm.ReadString(1);
finally
strm.Free;
end;
end;
var
strm : TStringStream;
s : string;
n : integer;
begin
strm := TStringStream.Create;
try
strm.WriteString('1ab3c'); //写入字符串
strm.Position := 0; //设定读取位置
s := strm.ReadString(1); //参数为读取的长度
//已知s的值为'1', 所以直接转整形了, 实际应用中不能这么干
n := strtoint(s);
finally
strm.Free;
end;
end;