Data segment: Difference between revisions

Content deleted Content added
Data: This not so in general. I guess maybe it is so on some embedded systems. In general data segment is separate and values are initialized when compiled.
Tags: Mobile edit Mobile web edit
m Add C examples + Fix highlight
Line 19:
The '''data segment''' contains initialized static variables, i.e. global variables and local static variables which have a defined value and can be modified. Examples in C include:
 
<syntaxhighlight lang="c">
int i = 3;
char a[] = "Hello World";
static int b = 2023; // Initialized static global variable
void foo (void) {
static int c = 2023; // Initialized static local variable
}
</syntaxhighlight>
 
=== BSS ===
{{main|BSS segment}}
The '''BSS segment''' contains uninitialized static data, both variables and constants, i.e. global variables and local static variables that are initialized to zero or do not have explicit initialization in source code. Examples in C include:
<syntaxhighlight lang="c">
 
static int i;
static char a[12];
</syntaxhighlight>
 
=== Heap ===
{{main|Manual memory management}}