does structure declaration occupies memory?

c, object, structure

Solution

The definition of a struct is normally not part of the binary in C. It only exists in your source code.

When the compiler sees references to your struct (typically for allocation or deallocation of space for an instance of this struct, access to its fields through an object variable, etc), it consults your struct definition in order to understand what the correct numbers are for that data type (it mainly wants to calculate data type sizes and field offsets).

When all this is done, the struct definition itself is forgotten and only the numbers are kept in the program, wherever they were actually used.

Therefore, if you don't reference your struct at all, then no traces of it should be present.

Problem

``` struct books { char name[100]; float price; int pages; }; ``` Declaring a structure Without creating an `object` of a `structure`, does the structure occupies space in memory for its `DATA MEMBERS`?

Original source