Can an address be assigned to a variable in C?

前端 未结 9 2109
孤城傲影
孤城傲影 2021-01-06 05:28

Is it possible to assign a variable the address you want, in the memory?

I tried to do so but I am getting an error as \"Lvalue required as left operand of assignmen

9条回答
  •  失恋的感觉
    2021-01-06 05:58

    There's probably no way to determine which address a variable will have. But as a last hope for you, there is something called "pointer", so you can modify a value on address 7200 (although this address will probably be inaccessible):

    int *i = (int *)7200;
    *i = 10;
    

提交回复
热议问题