Structure, Unions & Memory Allocation

Structure 
A data type to store groups of data of various of data types. As such, they are heterogeneous. Structure components consist of:
  • Member
  • Field
  • Element
There is a type of structure called a nested structure because one of it's element is another structure. (note that this should be declared first)

syntax: struct struct_name variable(value_m)
Union
A memory location that can be assigned for two or more variable with different data types. 
Enumeration
A data type with a predefined number of data.
Memory Allocation
The act of acquiring memory space in an OS to be used by a program.
There are 2 types:
  • Static
    • Can be assigned with name -> variable.
    • Allocated at compile time.
    • Stored at local stack memory.
    • Remain unchanged during the program run.
    • De-Allocated when the program ends.
  • Dynamic
    • Can be assigned with name
    • Allocated at run-time
    • Stored at heap memory
    • Can be De-Allocated at any time



Comments

Popular posts from this blog

Sorting & Searching

Pointer and Array in C Programming Language

Function and Recursion