Memory Allocation §
- when is the size to be allocated determined
- when does the allocation occur
malloc returns a
void *. If it fails, it will return
#include <stdlib.h> // ... int *i = malloc(sizeof(int)); int *array = malloc(4 * sizeof(int)); *i = 3; array = 5;
Memory allocated by
malloc is not initialized.
Space allocated via varaible declaratin is auto-deallocated when exiting scope.
Explicitly allocated memory must be deallocated explicitly using
free. Else, it is freed when the program terminates.
const int *ptr; // pointer to const int int *const ptr; // const pointer to int
Assignment expression evaluates to RHS.
Assembly Language §
cc -S main.c
Exception Flow §