Returns a string of length length
with the receiving string centered in it. The
pad characters are added as necessary to
make up length. The length must be a
positive whole number or zero. The default
pad character is blank. If the receiving
string is longer than length, it is
truncated at both ends to fit. If an odd number
of characters are truncated or added, the right-hand end loses or gains one
more character than the left-hand end.
Note
To avoid errors because
of the difference between British and American spellings, this method can
be called either center or
centre.
Example 5.87. String class — center method
Sayabc~center(7)--> " ABC "Sayabc~CENTER(8,"-")--> "--ABC---"Say"The blue sky"~centre(8)--> "e blue s"Say"The blue sky"~centre(7)--> "e blue "