Local initial values are stored at?

c, segments

Solution

10 is a constant, so the compiler will use the number 10 directly in the executable part of your program as part of the CPU instructions.

Here's the assembly produced on my system with `gcc`:

movl    $10, -4(%rbp)

(The `4` is because an `int` is 4 bytes long)

Note that all of these things are part of the implementation, but the above happens in practice. The language itself doesn't specify these details.

Problem

``` #include <stdio.h> int main() { int i = 10; return 0; } ``` In the above program, where exactly the value 10 is stored ? I understand the variable i is stored in the stack. stack is populated during run time. From "where exactly" 10 is coming from.

Original source