C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Data SegmentsTo understand the way our C program works, we need to understand the arrangement of the memory assigned to our program. All the variables, functions, and data structures are allocated memory into a special memory segment known as Data Segment. The data segment is mainly divided into four different parts which are specifically allocated to different types of data defined in our C program. The parts of Data segments are : 1. Data AreaIt is the permanent memory area. All static and external variables are stored in the data area. The variables which are stored in the data area exist until the program exits. 2. Code AreaIt is the memory area which can only be accessed by the function pointers. The size of the code area is fixed. 3. Heap AreaAs we know that C supports dynamic memory allocation. C provides the functions like malloc() and calloc() which are used to allocate the memory dynamically. Therefore, the heap area is used to store the data structures which are created by using dynamic memory allocation. The size of the heap area is variable and depends upon the free space in the memory. 4. Stack AreaStack area is divided into two parts namely: initialize and non-initialize. Initialize variables are given priority than non-initialize variables.
Next TopicFlow of C Program
|