Difference between

后端 未结 3 1618
囚心锁ツ
囚心锁ツ 2020-12-06 14:58

I want to get a detailed explanation on the difference between using %d and %p type for printing pointer.

Also Why does

3条回答
  •  孤街浪徒
    2020-12-06 15:40

    Those conversions are highly architecture dependent. One of the most clear distinctions are with the real mode 8086 where int is 16 bits and a (large model) pointer is 32 bits but has a segment and offset which are always written as segment:offset.

    %d    takes 16 bits and displays it as a signed value  123
    %p    takes a pointer and display it in address format    0fef:0004
    

    Since %p was introduced relatively recently I don't know of any implementations but a PDP-11 library ought to implement it by display the 16-bit address in octal.

提交回复
热议问题