CHARACTER ARRAYS
You can have arrays of characters. Text strings from the keyboard may be placed directly into the array elements. You can print out the entire character array contents. The following program illustrates how to do this,


	program CHARRAY (input,output );
	type word = PACKED ARRAY [1..10] of char;
	var  word1 : word;
	     loop  : integer;
	begin
	  writeln('Please enter in up to ten characters.');
	  readln( word1 );  { this reads ten characters directly from the
	                      standard input device, placing each character
	                      read into subsequent elements of word1 array }

	  writeln('The contents of word1 array is ');

	  for loop := 1 to 10 do                      {print out each element}
	     writeln('word1[',loop,'] is ',word1[loop] );

	  writeln('Word1 array contains ', word1 )   {print out entire array}
	end.

Note the declaration of PACKED ARRAY, and the use of just the array name in conjuction with the readln statement. If the user typed in
	Hello there
then the contents of the array word1 will be,
	 word1[1] = H
	 word1[2] = e
	 word1[3] = l
	 word1[4] = l
	 word1[5] = o
	 word1[6] =     { a space }
	 word1[7] = t
	 word1[8] = h
	 word1[9] = e
	 word1[10]= r

The entire contents of a packed array of type char can also be outputted to the screen simply the using the array name without an index value, ie, the statement

	 writeln('Word1 array contains ', word1 );
will print out all elements of the array word1, displaying
	 Hello ther


Copyright B Brown/P Henry/CIT, 1988-1997. All rights reserved.

1