You don't need to create a string-truncating function; printf() and sprintf() can truncate for you. The format "%20.20s" means "a 20 character right-justified string truncated at 20 characters".
Jeff japhy Pinyan,
P.L., P.M., P.O.D, X.S.:
Perl,
regex,
and perlhacker How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart