% sequence

This is a discussion on % sequence within the C Programming forums, part of the General Programming Boards category; I am trying to figure out the %sequence for short, unsigned long, long, unsigned long and long double....

From C99, since my knowledge of C is too deficient for me to figure it out myself offhand

EDIT:
But that they were introduced in C99 could explain why cppreference.com does not list them. For &#37;h the standard states that "the argument will have been promoted according to the integer promotions, but its value shall be converted to short int or unsigned short int before printing".

>All the sources I've seen suggest that all ints (unsigned char,
>short, int, long) use %d and just get upgraded on their way in?
What sources? Except for long long, those are all C89 format specifiers, and unless you have a good reason, you should match the type as closely as you can.

And arguments to printf (and all other variadic functions) are upgraded to integer and double for "short / char" and "float" respectively, but where "long" is different from "int", the int is not turned into a long, nor is "double" turned into a "long double", so using the correct sequence is important to ensure portability.