What I want is to define an array of Strings in Ada.

I'm trying to execute this code:

```
type String is array (Positive range <>) of Character;
type lexicon is array(1..7) of String(1..20);
nomFumadors : lexicon := ("Macia","Xisco","Toni","Laura","Rocky","Paz");
nomNoFumadors : lexicon := ("Marina","Marta","Joan","Africa","America");

```

And the compiler says:

```
warning:wrong length for array of subtype of "String" defined at line 42

```

My line 42 is this:

```
type lexicon is array(1..7) of String(1..20);

```

But compailer says the warning is in line 43 and 44: what are these:

```
nomFumadors : lexicon := ("Macia","Xisco","Toni","Laura","Rocky","Paz");
nomNoFumadors : lexicon := ("Marina","Marta","Joan","Africa","America");

```

Can somebody help me with that?
['https://Stackoverflow.com/questions/70968102', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12058857/']
Another option is `Unbounded_String` (as its name suggests, length is variable and unlimited):

```
with Ada.Strings.Unbounded;

procedure Fumador is
  use Ada.Strings.Unbounded;

  subtype VString is Unbounded_String;
  function "+" (Source : in String) return VString renames To_Unbounded_String;

  type Lexicon is array (Integer range <>) of VString;  --  Unknown number of people.
  nomFumadors : Lexicon := (+"Macia", +"Xisco", +"Toni", +"Laura", +"Rocky", +"Paz");
  nomNoFumadors : Lexicon := (+"Marina", +"Marta", +"Joan", +"Africa", +"America");

begin
  null;
end;

```
Similar to Jeff Carter's answer, but using a function to coerce any string into a fixed string ...

```
procedure Main is

   subtype Lexicon_Data is String (1 .. 20);
   type Lexicon is array (1 .. 7) of Lexicon_Data;

   function To_Lexicon_Data
     (Value : in String)
      return Lexicon_Data
   is
      Result : Lexicon_Data;
   begin

      if Value'Length < 1 then
         -- Empty string returns a bunch of spaces
         Result := (others => ' ');

      else
         declare
            Offset : constant Natural :=
              Value'First - Lexicon_Data'First;
         begin

            if Value'Length > Lexicon_Data'Length then
               -- Length exceeds range, so truncate
               Result (Lexicon_Data'Range) := Lexicon_Data
                 (Value (Offset + 1 .. Offset + Lexicon_Data'Length));

            else
               -- Copy into result, and pad right with spaces
               Result := (others => ' ');
               Result (Lexicon_Data'First .. Value'Length) :=
                 (Value (Offset + 1 .. Offset + Value'Length));

            end if;

         end;

      end if;

      return Result;

   end To_Lexicon_Data;

   nomFumadors : constant Lexicon :=
     (To_Lexicon_Data ("Macia"),
      To_Lexicon_Data ("Xisco"),
      To_Lexicon_Data ("Toni"),
      To_Lexicon_Data ("Laura"),
      To_Lexicon_Data ("Rocky"),
      To_Lexicon_Data ("Paz"),
      To_Lexicon_Data ("Mark"));

begin
   --  Insert code here.
   null;
end Main;

```

If you wanted to prove AoRTE (ie SparkAda) then the declaration for Result in the function becomes

```
Result : Lexicon_Data
   with Relaxed_Initialization;

```

.. and the function To\_Lexicon\_Data is proved as being runtime error free.

Note the extra item for Lexicon, Mark, since you need seven items for the Lexicon declaration to be valid.