Do sprintf transformation types and parameter types have to be the same?
This involves the upward conversion of data types, which can only be converted to higher-level types, such as unsigned char->; char-& gt; Int In this example, you are equivalent to "filling" the variable of unsigned long integer into a plastic "space". Think about it, the system first thinks that you have to input a plastic, and has prepared a 2-byte space for you. As a result, if you give him an unsigned long plastic with a length of 4 bytes, there is no way to fit it into this space. But if you enter a plastic, the system will allocate a space with a length of 4 bytes, so you can enter any plastic data less than this length in such a large space, such as unsigned char( 1 byte), int(2 bytes) and so on. Ok, what you said later, if b is short int, this is ok, because short int is 2 bytes, which just meets the standard of' %d'. That's all. I may be confused. If you don't understand, ask me