passing value to a function

How can I replace the 'radio.write' function with 'sprintf'

You can't. What sprintf() does is populate the array that you want the radio.write() method to send.