const volatile staticBut what do they mean? Well, in your computer's memory there are several sections, called segments. There are 6 used by the C language: Data, rodata, bss, heap, stack, text. Each of these has a different way to put data in it.
float x; //bss: uninitialised space
float y = 2.0; //data: initialised space
const float pi = 3.1415; //rodata: read only space
int main(){
int i; //stack: local space
static int j; //bss: uninitialised space
static int k = 4; //data: initialised space
char * s = malloc(20); //heap: dynamically allocated space
}
So, the rules are:code goes in the text segment.
global stuff
goes in bss if not initialised
goes in data if initialised
goes in rodata if const.
local stuff
normally goes on the stack
if static
goes in bss if not initialised
goes in data if initialised
goes in rodata if const
dynamic allocations come from the heap.
Ja mata!


Sign In
Create Account


Back to top









