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 solution is to use String, truncate long strings, and pad short strings:

```
Max : constant := 20;
subtype S20 is String (1 .. Max);
type Lexicon is array (1 .. 7) of S20;
function To20 (S : in String) return S20 is
   (if S'Length >= Max then S (S'First .. S'First + Max - 1)
    else S & (S'Length + 1 .. Max => ' ') );
V : Lexicon := (To20 (""), To20 ("Hello"), To20 ("1234567890123456789012345"), ...

```
Building upon the solution by Mark, but simplifying thanks to the operations from [`Ada.Strings.Fixed`](https://en.wikibooks.org/wiki/Ada_Programming/Libraries/Ada.Strings.Fixed).

```ada
with Ada.Strings.Fixed;
with Ada.Text_IO;

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
   begin
      return Ada.Strings.Fixed.Head (Value, Lexicon_Data'Length);
   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

   for Item of nomFumadors loop
      Ada.Text_IO.Put_Line (Ada.Strings.Fixed.Trim (Item, Ada.Strings.Both));
   end loop;

end Main;

```