Lecture 3 Flashcards
expiration on address off something
double d = 3.1416;
[—] [][][][][][][][][][][][][][][][][][][][][]
char ch = (char)&d;
[—]
invade
c_5
c_6
What is &
is the address of the lowest byte
struct
it’s basically the sum of its parts,
packs all of those bytes as tightly as possible
- the address of struct is always coincident with the address of the first field
- memory is stacked 4 bytes on top of 4
- c_7
- when I say var.prob, actually I go to the struct to find out the prob index, then based on this index I go to memory to place some zeros and ones
case int* to struct*
c_8
the array itself is synonymous with the address of zeroth entre
array = &array[0]
that’s why when you pass an array to a helper function or any function whatsoever you’re not passing the entire array you’re just identifying the location of the 0th entry and from that you can access anything legitimately beyond it as long as you know how long the array
array invade
- c_9
- valid in c
- 10 x size of int from the base address
array access synonymous
c_10
array access invade
pretend just for me that this is a char
c_11
why string resides in the head instead of the stack?
because unless we initialize it with a value in the run time we don’t really know what is the size of the string.
so what we do Is create the var in the heap with \0 at the end and store a pointer to this string in the stack.
we should dereference (arr + number) in order to get the value
because this wll return a refrense
strcopy vs strdup
strcopy take a reference
implementation of empty string
\0
swap function in c
c_12
how to fuck yourself in a nutshell
https://see.stanford.edu/materials/icsppcs107/memory.pdf