Tuesday, December 4, 2018

Structures and Unions & Memory Allocation

Halo guys gue abis belajar ini nihm nih gue jelasin yak

Apa itu struktur? nih arti struktur yg gue dapat dari bimay

Structure is a data type to store group of data with various of data type
syntax nya


Syntax
struct name_structure {
    dataType1 name_field1;
    dataType2 name_field2;
   
};


lanjut unions

Union is used for memory join. By using union, a memory location can be assigned for two or more variable with different data types


trus syntax

union  name_union{
     typedata1  name_var1 ;
     typedata2   name_var2;
     ……
} name_var_union;



memory


Memory Allocation as a data store:
1. 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 end
2. dynamic
    Ä can be assigned with name
    Ä allocated at run-time
    Ä stored at heap memory
    Ä can be de-allocated at any time


itu aja sih yg gue tankep maksihh

bimay sr