Format specifier x

前端 未结 4 829
离开以前
离开以前 2021-02-01 15:19

I have a simple program :

#include 
int main()
{
        long i = 16843009;
        printf (\"%02x \\n\" ,i);
}

I am using

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-01 15:48

    %x is a format specifier that format and output the hex value. If you are providing int or long value, it will convert it to hex value.

    %02x means if your provided value is less than two digits then 0 will be prepended.

    You provided value 16843009 and it has been converted to 1010101 which a hex value.

提交回复
热议问题