COMP 206 Lecture Notes - Lecture 25: Object-Oriented Programming, Function Pointer, C Dynamic Memory Allocation
Document Summary
Declaration char all_memory[1000000]; int main() int *array = (int*) malloc(1000*sizeof(int)); array[0] = 5; array[999] = 5; int *array2 = &(all_memory[5000]); The power that malloc gives us is the power to scale memory usage of programs dynamically. Without malloc, we must dedicate large amounts of memory to running even the smallest programs. Linked lists start with pointer and end with null. Each item in the list is called a node. All of a progra(cid:373)"s code live i(cid:374) (cid:373)e(cid:373)ory c gives us access that that memory using pointers. In addition to pointing to data, we can also point to functions. These include those we code ourselves, and built-in functions in libraries.