I am printing information about a struct which only contains information which will all be a single digit (small indices and char which act as bools mostly).
I want my printf
calls to be as efficient as possible. So would it be better to use the normal %i
/%d
format specifiers, or is it better to use %c
and add 0x30
('0'
) to the number, since then there shouldn't need to be any formatting for printf
to do?
Edit/Clarification: I have profiled some small programs which try both techniques, and the %c
can be faster. If this were for production code, I would just stick to the %d
, but this is specifically for speed-based competitions. (sorry because that wasn't clear before).