in reply to sprintf question
printf(...) is equivalent to print sprintf(...)
You'd use sprintf when you need to have a formatted string in memory, and printf when you want to output a formatted string.