C Dynamic Memory Flashcards
(7 cards)
1
Q
What is the Heap Used for?
A
Dynamic allocation
2
Q
What does malloc() and free() do?
A
Malloc assigns memory and free frees it once we are done
3
Q
What is size_t?
A
Just unsigned int
4
Q
What happens if request more memory than we have
A
Returns null
5
Q
If I wanted to createa typedef string, how would I initilize it in main?
A
In main, you would want to use strcpy(location, name);
6
Q
What is a memory leak?
A
Must free() memory or we will have memory on the heap we can no longer get to
7
Q
When making a typedef struct, when should you use sizeof and strlen/strcpy?
A
Use sizeof to malloc the pointer object while use strlen/strcpy if you don’t have a pointer object