in C, if I declare a static variable inside a local strucutre, where does the static variable get placed ?
Since the struct is in the stack, will the static variable also be in the stack ?
in C, if I declare a static variable inside a local strucutre, where does
Share
In current C the keyword
staticis meaningless inside a structure. You should get an error from the compiler.If by “static” you mean “not allocated using malloc”: the member of a structure is always stored in the same place as the rest of the structure. If said member is a pointer, it can point to memory in the same region or not.