Week 4 - Memory Flashcards

1
Q

What is a pointer?

A

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)

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

malloc is a function which used to

A

allocate some number of bytes in memory

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

free is a function which used to

A

free memory

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

what are garbage values and when do they appear?

A

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

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

The 4 sections of the Memory layout

A

1-machine code
2-globals
3-heap
4-stack

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

What will happen in the machine code section?

A

here is where our compiler starts to translate source code into machine code

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

What will happen in the globals section?

A

here is where will our program read the global variables that we declared in our code

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

What will happen in the heap section?

A

here is an empty area from wheremalloccan get free memory for our program to use.

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

What will happen in the stack section?

A

it is used by functions and local variables that we created in our program as they are called, and grows upwards.

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

What is the difference between & and *?

A

& Provides the address of something stored in memory.
* Instructs the compiler to go to a location in memory.

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