with Ada.Text_IO;
with Ada.Text_IO.Unbounded_IO;
with Ada.Strings.Unbounded;      use Ada.Strings.Unbounded;
with Ada.Containers.Vectors;     use Ada.Containers;
 
procedure Quotes is
   package IO renames Ada.Text_IO;
   package SUIO renames Ada.Text_IO.Unbounded_IO;
   package Quote_Container is new Vectors (Natural, Unbounded_String);
   use Quote_Container;
   Quotes    : Vector;
   Q_Cursor  : Cursor;
   Input     : IO.File_Type;
begin
   IO.Open (File => Input,
            Mode => IO.In_File,
            Name => "quotes.txt");
   while not IO.End_Of_File (File => Input) loop
      Quotes.Append (New_Item => SUIO.Get_Line (File => Input));
   end loop;
   IO.Close (Input);
 
   Q_Cursor := Quotes.Last;
   SUIO.Put_Line (Item => Element (Position => Q_Cursor));
 
   Quotes.Clear;
 
   Q_Cursor := Quotes.Last;
   if Q_Cursor /= No_Element then
      SUIO.Put_Line (Item => Element (Position => Q_Cursor));
   else
      IO.Put_Line (Item => "No Elements in vector");
   end if;
end Quotes;

Go back


Navigation