Three storage areas of a C program? -
i bit puzzled how 3 different storage areas in c programme work. understand there stack, dynamic storage, , static storage. far understand going on.
stack - local variables , formal value parameters. dynamic storage - ? static storage - contiguous blocks of memoryi unsure stored in dynamic storage area , don't know if have right static storage area.
c has 4 storage durations: static, thread (since c11), automatic, , allocated. dynamic storage duration called allocated in c standard terminology.
int = 0; // static storage duration static int b = 0; // static storage duration _thread_local int c = 0; // thread storage duration void bla(int d) // d has automatic storage duration { int e; // automatic storage duration static int f; // static storage duration int *p = malloc(42 * sizeof *p); // object allocated malloc // has allocated storage duration }
c storage
No comments:
Post a Comment