TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

C Data Segments

C Data Segments with programming examples for beginners and professionals covering concepts, control statements, c array, c pointers, c structures, c union, c strings and more.

<< Back to C

Data Segments

To 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.

Data Segments

The parts of Data segments are :

1. Data Area

It 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 Area

It is the memory area which can only be accessed by the function pointers. The size of the code area is fixed.

3. Heap Area

As 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 Area

Stack area is divided into two parts namely: initialize and non-initialize. Initialize variables are given priority than non-initialize variables.

  1. All the automatic variables get memory into stack area.
  2. Constants in c get stored in the stack area.
  3. All the local variables of the default storage class get stored in the stack area.
  4. Function parameters and return value get stored in the stack area.
  5. Stack area is the temporary memory area as the variables stored in the stack area are deleted whenever the program reaches out of scope.
Next TopicFlow of C Program




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf