我的程序如下:
procedure TForm1.Button2Click(Sender: TObject);
var
s:string;
i,j:integer;
begin
s:='int i;';
i:=1;
for j:=1 to Length(s) do
if s[j]='' then
ShowMessage(IntToStr(j)+'is space');
end;我单步跟踪,发现但s[j]是空字符时,它也跳过了ShowMessage。为什么呀?
应该怎么判断呢?
procedure TForm1.Button2Click(Sender: TObject);
var
s:string;
i,j:integer;
begin
s:='int i;';
i:=1;
for j:=1 to Length(s) do
if s[j]='' then
ShowMessage(IntToStr(j)+'is space');
end;我单步跟踪,发现但s[j]是空字符时,它也跳过了ShowMessage。为什么呀?
应该怎么判断呢?
哎呀,发现BCB和DELPHI在字符串处理上还是有区别的!
s:='int i;';
i:=1;
for j:=1 to Length(s) do
if s[j]=' ' then
ShowMessage(IntToStr(j)+'is space');
end;