Say I put a character array of the form "char variable[SIZE]" in the definition of an external structure.
How is the initialization/destruction of the array handled with relation to the creation/destruction of objects of this structure type?
Say I put a character array of the form "char variable[SIZE]" in the definition of an external structure.
How is the initialization/destruction of the array handled with relation to the creation/destruction of objects of this structure type?
Every object has an array in it, so the array is created when the object is created and destroyed when the object is destroyed. That is, the scope of every member of the object is the same as the scope of the object.
In C there's no "constructor/destructor" concept. An array in a struct will be set to zero on global & static variables, and random values (whatever happens to be on the stack/heap location where it ends up) in any other situation.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.