Week 4 - Memory Flashcards
What is a pointer?
It is a variable that stores an address in memory, where some other variable might be stored (like an arrow that guides you to another area)
malloc is a function which used to
allocate some number of bytes in memory
free is a function which used to
free memory
what are garbage values and when do they appear?
They are unknown values that were in memory, from whatever program was running on our computer before. and they appear when we have no specific values in our program
The 4 sections of the Memory layout
1-machine code
2-globals
3-heap
4-stack
What will happen in the machine code section?
here is where our compiler starts to translate source code into machine code
What will happen in the globals section?
here is where will our program read the global variables that we declared in our code
What will happen in the heap section?
here is an empty area from wheremalloccan get free memory for our program to use.
What will happen in the stack section?
it is used by functions and local variables that we created in our program as they are called, and grows upwards.
What is the difference between & and *?
& Provides the address of something stored in memory.
* Instructs the compiler to go to a location in memory.