Is primitive assigned a memory address?

后端 未结 4 2064

I am trying to understand the process of declaration and assignment of a primitive type at the back stage.

  1. int i;
  2. i = 3;
4条回答
  •  执念已碎
    2021-01-12 17:34

    Assuming you're talking about C or C++ (I can't tell), yes. You can access the address like so:

    int i = 3;
    
    int *k = &i; // k now is a pointer to i
    
    *k = 4; // assigns the value k points to (i) to 4, i is now 4
    

提交回复
热议问题