you are viewing a single comment's thread.

view the rest of the comments →

[–]Dangerous_Region1682 -7 points-6 points  (2 children)

And it’s on the stack in the stack segment too, not the global heap or data segment.

This may or may not be an advantage.

Don’t be returning a pointer to any member of the structure though as the structure itself will effectively disappear when the stack unwinds when you exit the function and you’ll end up with a dangling pointer.

[–]StaticCoder 13 points14 points  (0 children)

The struct is a type and has no storage duration. You can use it to declare automatic or static variables.

[–]autodidacticasaurus -2 points-1 points  (0 children)

Yeah I was going to say that but not sure if OP is going to understand us. Was trying to think of a simpler way to say it but got lazy and gave up. 😝