implementation of printf function