Correct format specifier to print pointer or address?

前端 未结 5 1830
自闭症患者
自闭症患者 2020-11-21 13:17

Which format specifier should I be using to print the address of a variable? I am confused between the below lot.

%u - unsigned integer

%x

5条回答
  •  耶瑟儿~
    2020-11-21 13:44

    You can use %x or %X or %p; all of them are correct.

    • If you use %x, the address is given as lowercase, for example: a3bfbc4
    • If you use %X, the address is given as uppercase, for example: A3BFBC4

    Both of these are correct.

    If you use %x or %X it's considering six positions for the address, and if you use %p it's considering eight positions for the address. For example:

提交回复
热议问题