2
votes

I am getting an 'Illegal Expression' error when creating a const char array of const chars.

Program Foo; (*excerpt*)
Const
  X : Char = 'X';
  O : Char = 'O';
  P : Array [1..2] of Char = (X,O);
Begin
  (*stuff*)
End.
2

2 Answers

3
votes

I'm typing this from a device that doesn't have pascal. So I can't verify it, but this probably works:

Const 
X = 'x';
O = 'o';
P : array[1..2] of char = (o,x);
2
votes

You could also have written

Const
 X : Char = 'X';
 O : Char = 'O';
 P : Array [1..2] of Char = ('X', 'O');

to achieve the same effect