Lecture 3 - Memory & Pointers Flashcards
What is memory?
Part of the computer which is used to store data and program instructions for retrieval.
What can we think of memory as
a sorting cabinet, where each box stores the value and the label is the variable name
What notion do we have in memory?
A notion of spatial locality. This is an important property of which caches make use of. This is when a line of memory is fetched,so close by data that may be needed soon can be loaded quickly (is cached).
- We are making a guess as to what data will be needed
How long are addresses in 64 bit architecture?
64 bits or 8 bytes
How big is a memory addressed by an address?
a byte (8 bits)
How many addresses can a 64 bit architecture have ?
2^64 addresses to bytes
Do we need to get the full byte to modify a single bit ?
YES
What doe (1 «_space;3) mean ?
A left shift (multiplication by 2).
What does & do?
Gets the address of a variable -> pointer.
what is sizeof()
A function that gets the size of a variable in bytes
What is a pointer?
A variable which has the value , which is the address of a memory location. It essentially points to where the data is.
What is * called.
The dereference operator?
What does * do?
It gets the value at the address.
Is every pointer the same size?
YES
How big are pointers in 64 bit architecture?
8 bytes (64 bits)
Is pointer a normal variable.
Yes in a sense that is also has to be stored at some memory location.
What is int * * name?
A pointer to a pointer which points to data.
How are arguments passed to a function in C?
By value?
Are the any exceptions to call by value?
Yes, arrays. Pointers are also copied by the value they point to can be manipulated directly.