Search code examples
cvariablesmemory-managementconstantsglobal

Where are constant variables stored in C?


I wonder where constant variables are stored. Is it in the same memory area as global variables? Or is it on the stack?


Solution

  • How they are stored is an implementation detail (depends on the compiler).

    For example, in the GCC compiler, on most machines, read-only variables, constants, and jump tables are placed in the text section.