stack implementation to print characters of a string from back