Where are constant variables stored in C?

user188276 picture user188276 · Oct 16, 2009 · Viewed 82.4k times · Source

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

Answer

Robert Harvey picture Robert Harvey · Oct 16, 2009

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.