Skip to content

Instantly share code, notes, and snippets.

@emadflash
Created January 5, 2021 13:32
Show Gist options
  • Save emadflash/473af94c54e766b77f3874609ed01ea3 to your computer and use it in GitHub Desktop.
Save emadflash/473af94c54e766b77f3874609ed01ea3 to your computer and use it in GitHub Desktop.
memory segmentation in c
#include<stdio.h>
#include<stdlib.h>
/*
* text/code section
* data - initialized var
* bss - un-initialized var
* heap - memory allocated
* stack - functions
*/
// DATA
static global_initialized_var = 1;
// BSS
int global_uninitialized_var;
int main(){
// STACK
static int initialized_var = 1;
// HEAP
int* heap_var_ptr = (int*) malloc(4);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment