CIS 2500 Lecture Notes - Lecture 10: Memory Management, Null Pointer, C Dynamic Memory Allocation

85 views5 pages

Document Summary

Lecture 10: the quiz this week consists of 5 programming problems, mostly focusing on memory and pointers. Review: dynamic memory allocation: dynamic memory allocation is used to create a variable of a size determined while the program is running (not when it is compiled), terms, compile time, run time. /* * means that you take the value stored in ptr and reference the memory it points at */ printf(%dn, *ptr); Review: how arrays are stored: arrays are simply a sequence of memory locations with some convenient access structures built you can print the address of an element of an array using &(a[3]) Review: allocating 100 integers int * numbers; numbers = malloc (sizeof(int) * 100): malloc() returns the address of the memory that has been allocated. This is stored in the pointer variable numbers: now you can access the allocated memory using a pointer and pointer arithmetic, or you can treat it as an array.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents