As soon as the function returns, the data will not be destroyed, but will most likely be overwritten by the next function call. You may be lucky and it may still be there, but this behavior is undefined. You should not rely on this.
Here's what could happen: during a function, the stack looks like this:
"--------------------------- | caller function data | ---------------------------- | Ten[9] | | Ten[8] | | ... | | Ten[0] | ---------------------------"
Immediately after the function exits, it will probably look the same. But if the caller calls another function like this,
void some_func() { Gene g; ... }
the stack will now look:
"--------------------------- | caller function data | ---------------------------- | g | ---------------------------- | Ten[8] | | ... | | Ten[0] | ---------------------------"
Some data may be overwritten unnoticed (in this case, Ten[9] ), and your code will not know this. You must allocate the data on the heap with malloc() and explicitly free it with free() .
Zifre source share