Lecture 3 Flashcards

1
Q

expiration on address off something

A

double d = 3.1416;
[—] [][][][][][][][][][][][][][][][][][][][][]
char ch = (char)&d;
[—]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

invade

A

c_5

c_6

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is &

A

is the address of the lowest byte

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

struct

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

case int* to struct*

A

c_8

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

the array itself is synonymous with the address of zeroth entre

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

array invade

A
  • c_9
  • valid in c
  • 10 x size of int from the base address
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

array access synonymous

A

c_10

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

array access invade

A

pretend just for me that this is a char

c_11

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

why string resides in the head instead of the stack?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

we should dereference (arr + number) in order to get the value

A

because this wll return a refrense

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

strcopy vs strdup

A

strcopy take a reference

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

implementation of empty string

A

\0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

swap function in c

A

c_12

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

how to fuck yourself in a nutshell

A

https://see.stanford.edu/materials/icsppcs107/memory.pdf

How well did you know this?
1
Not at all
2
3
4
5
Perfectly