Skip to main content
gamedev.net
🔒 Locked

using the sprintf()

Started by shvalb 0 replies 300+ views
Original Post
shvalb
shvalb
Hi. I have a little question, I use the sprintf() like this: ::sprintf(temp, "0%x%x", pUni->charValAndLang[k+1], pUni->charValAndLang[k]); so the 'temp' (for instance) is 05d0, my question is, supposed I would like it to be %05%d0, how to I set the % char in the sprintf() ?? it supposed to be something like: ::sprintf(temp, "%0%x%%x", pUni->charValAndLang[k+1], pUni->charValAndLang[k]); no ? Thanks.
Zahlman
Zahlman
Use '%%' to encode a literal % sign within the format string. Therefore:
sprintf(temp, "%%0%x%%%x", pUni->charValAndLang[k+1], pUni->charValAndLang[k]);


However, consider the possibility that there is an easier way to do whatever it is you're trying to do (especially in C++ rather than plain old C).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.