在Ada中,可以使用以下代码忽略初始空格的子程序:
procedure Ignore_Initial_Spaces is
Input_Line : String (1 .. 80);
begin
-- Read in the line
Get_Line (Input_Line, Last => Length(Input_Line));
-- Find the first non-blank character
declare
I : Integer := Input_Line'First;
begin
while Input_Line(I) = ' ' loop
I := I + 1;
end loop;
-- Process the rest of the line
for J in I .. Input_Line'Last loop
-- do something with Input_Line(J)
end loop;
end;
end Ignore_Initial_Spaces;