Question: I have a doubt about C initializers. If we user an initializer like:

```
int a[2] = {1, 3}; 

```

in a static storage variable, I understand (think) that the compiler puts that data automatically in the .data of the elf file. But when we do that inside a function to initialize a variable that will be in the stack what happens? Does the compiler generate code that "fills" that variable in runtime? If so why can't we do something like:

```
struct mystruct {
    int x;
    int y;
};

int main(){

   struct mystruct foo;
   foo = {1, 2};

   return 0;
}

```

Answer: 
It's just a question of syntax.

Since C99, you can do precisely that, but you need an explicit cast in order to tell the compiler what the {...} block that follows is:

```
foo = (struct mystruct){1, 2};

```

Note that the above is an assignment, not an initialization. So the following is also legal:

```
for (int i = 0; i < 10; ++i) {
  foo = (struct mystruct){i, 2*i};
  // Do something with foo
}

```
you need to distinguish between code that is functionally different and code that is syntactically different. Compiler and language designers and writers first focus on providing features, like static data, vs local (stack), ....

A secondary consideration is 'syntactical sugar' that is simplified syntax for doing something that can already be done

IN your example

```
  struct mystruct foo;
   foo = {1, 2};

```

is the same as

```
  struct mystruct foo;
   foo.x = 1;
   foo.y = 2;

```

you can argue that the first one is simpler and clearer , but is obviously not common enough. Note one language did change syntax. C++ changed your example to

```
   mystruct foo;
   foo.x = 1;
   foo.y = 2;

```

because it was so common to typedef structs that c++ decided to make structs and classes types automatically.

Edit: I note somebody put in the correct syntax for your initializer. My view on it is that this is not really simpler: the fact that the syntax is a little convoluted forces a bubble in the readers pipeline. And it doesnt save much typing either