Format specifier x

前端 未结 4 832
离开以前
离开以前 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:31

    %02x means print at least 2 digits, prepend it with 0's if there's less. In your case it's 7 digits, so you get no extra 0 in front.

    Also, %x is for int, but you have a long. Try %08lx instead.

提交回复
热议问题