How to print out the memory contents of a variable in C?

后端 未结 9 762
滥情空心
滥情空心 2020-12-13 14:48

Suppose I do a

double d = 234.5;

I want to see the memory contents of d [the whole 8 bytes]

How do I do that?

9条回答
  •  难免孤独
    2020-12-13 15:10

    I think you can use shift operation and mask to "mask out" the actual bits.

    int t = 128;

    for(int i=0;i<8;++i) { printf("%d", p & t);

    p =>> 1;

    t =>> 1; }

提交回复
热议问题