【发布时间】:2014-06-25 01:48:15
【问题描述】:
我想在我的数组中的指定索引处存储由空格分隔的每个字符块。这是我的代码:
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Read is
Input_File : File_Type;
type Arr_Type is array (Integer range <>) of Character;
Arr : Arr_Type (1 .. 3);
begin
Ada.Text_IO.Open (File => Input_File, Mode => Ada.Text_IO.In_File, Name => "input.txt");
while not End_OF_File (Input_File) loop
Ada.Text_IO.Get (File => Input_File, Item => Arr(1));
Ada.Text_IO.Put (Item => Arr(1));
end loop;
Ada.Text_IO.Close (File => Input_File);
end Test_Read;
文件“input.txt”包含:
ABCD EFGH IJK
我为 Put(Arr(1)) 得到的输出是整行:
ABCD EFGH IJK
Put(Arr(1)) 我想要的输出是:
ABCD
【问题讨论】: