[fpc-pascal] Array initialization

Andrew Brunner andrew.t.brunner at gmail.com
Wed Mar 18 02:57:37 CET 2009


var
  c1 : array[1..10]  of char;
begin
  fillchar(c1[1],5,0);
  fillchar(c1[5],5,#32);

You might need @ sign in front of c1 though...
...or...

const
  c1:array[1..10] of char = '123456789a';



On Tue, Mar 17, 2009 at 5:50 PM, Francisco Reyes <lists at stringsutils.com> wrote:
> On the following URL,
> http://web.mit.edu/sunsoft_v5.1/www/pascal/lang_ref/ref_data.doc.html#1212,
> I found some different syntax to initialize an array.
>
> Examples there..
> var
> c1 :  array[1..10] of char := '123456';
> int2 : array[1..100] of integer := [50 of 1, 50 of 2];
>
> Tried those, but didn't seem to to work.
>
> Is a loop the only way to initialize all the values in an array other than
> Values: array[1..2] of integer = (0,0);
>
> In the program I am working on, Values will be an array of 128 integers and
> I would like to initialize them to 0.
>
> Right now I just using:
> for InitialLoop := 1 to 128 do
>        Values[InitialLoop] :=0;
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



More information about the fpc-pascal mailing list