The Ada Program: name.adb

  1 -- name.adb:  pointers to strings of length 20
  2 
  3 with Ada.Text_IO;
  4 use Ada;
  5 
  6 procedure Name is
  7 
  8    subtype Name_String is String (1..20);
  9    type Name_Pointer is access Name_String;
 10 
 11    First, Middle, Last : Name_Pointer;
 12 
 13 begin
 14 
 15    First  := new Name_String;
 16    Middle := new Name_String'(1..20 => 'A');
 17    Last   := new Name_String'("This string has 20 c");
 18 
 19    Text_IO.Put (Item => Last.all);
 20    Text_IO.Put (Item => Last.all(2..5));
 21    Text_IO.Put (Item => Last.all(7));
 22 
 23    Middle.all (1..5) := "Hello";
 24    Middle.all (18)   := 'B';
 25 
 26 end Name;