Deep Analysis of Const Qualifier in C

前端 未结 9 1010
离开以前
离开以前 2020-11-30 08:26

Where does a const variable gets stored exactly and how does it behaviour change? Say for example:

const int i=10; // stores where ?  
main()  
         


        
9条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-30 08:59

    It really shouldn't work.

    Constants are generally not stored anywhere. They are expanded inline.

    It's possible that your compiler is being nice to you and giving you a memory location to modify, but normally that's impossible.

    What warnings are you getting? I imagine you must get some...

提交回复
热议问题