When a const is declared in C where in Memory the value get stored?
Const Declaration
Collapse
X
-
The const value is stored based on the storage class specifier.
[code=c]
//In a function:
auto const int var = 10; //stored in the stack frame
const int var = 10; //same as auto const var = 10;
static const int var = 10; //stored in the static memory pool
register const int var = 10; //you suggest var to be stored in a processor register
//
//Outside a function:
const int var = 10; //stored in the static memory pool with external linkage
static const int var = 10; //stored in the static memory pool with internal linkage
register const int var = 10; //you suggest var to be stored in a processor register
[/code]Comment
Comment