mercredi 22 juillet 2020

Where is variable data stored in C/C++?

While I know that the memory layout is supposed to be :

Text Segment : Executable instructions(I am guessing machine code in binary)

Initialised Data Segment : Global and static variables that are initialised, if static int a = 10; a is stored here and I am assuming the value 10 is also stored here?

Uninitialised Data Segment : Stores uninitialised variables. static int a; ‘a’ will be stored here.

Stack : Local, temporary variables, recursive function calls, return address.

Heap : Dynamic memory allocated to a variable through malloc or realloc.

char *s = “hello world”

Where will the pointer variable and the string “hello world” be stored?

Aucun commentaire:

Enregistrer un commentaire