fix sprintf return value. It retures the number of characters.