search

Home  >  Q&A  >  body text

c++ - c语言中普通变量

c语言中定义的变量在定义时不占用内存,但是赋值时占用内存的情况是怎么样的,和实际赋的那个值在内存中有什么关系吗

高洛峰高洛峰2803 days ago534

reply all(2)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-17 13:05:49

    Memory is allocated when the variable is defined and does not occupy memory when it is declared. A variable occupies a fixed size of memory from the time it is defined until the end of the variable's life cycle. It has nothing to do with whether or what data is saved in it

    reply
    0
  • 迷茫

    迷茫2017-04-17 13:05:49

    Variables occupy memory when they are defined. The occupied size varies depending on the variable type. Assignment only changes the value stored in the memory block and has nothing to do with the allocated memory address.

    reply
    0
  • Cancelreply