Can I Allocate a specific memory address using pointers in c++?

后端 未结 4 1743
太阳男子
太阳男子 2020-12-02 01:43

Can I Allocate a specitic memory address using pointers in c++ ?

For example: Allocate This memory address 25D4C3FA and put 4 in it.

4条回答
  •  时光说笑
    2020-12-02 02:38

    Assuming that by allocate you actually mean access,

    You can, but if the address is invalid or not accessible then deferencing the address will result in Undefined Behavior.
    So it is not a good idea to do so.

提交回复
热议问题