Functions and Memory in C: Allocating Memory on the Heap

C programming    |    Intermediate
  • 11 Videos | 1h 32m 2s
  • Includes Assessment
  • Earns a Badge
C programmers can commonly use two kinds of memory: stack and heap. While stack memory is used to store local variables and is fully managed by C, it does have major limitations that are mitigated by heap memory. In this course, you will compare stack and heap memory, exploring the advantages and limitations of each. Then, you will allocate memory using the malloc() function and deallocate memory using free(). Next, you will examine dangling memory issues that can cause potentially dangerous security issues. You will also explore other common allocation functions like calloc() to zero out memory and realloc() to help when you underestimate how much memory an array will require. Finally, you will focus on pointers to struct objects. After completing this course, you'll be able to allocate memory malloc, calloc, and realloc; free memory; use pointers to structs; and avoid problems related to dangling pointers and memory leaks.

WHAT YOU WILL LEARN

  • discover the key concepts covered in this course
    contrast stack and heap memory
    use malloc() to allocate memory on the heap
    use the free() method to free stack memory that is not allocated
    allocate space for arrays using malloc()
    return pointers to heap locations from functions
  • distinguish between dangling memory and memory leaks
    contrast malloc(), calloc(), and realloc()
    create pointers on struct objects
    create pointer fields in structs
    summarize the key concepts covered in this course

IN THIS COURSE

  • Playable
    1. 
    Course Overview
    2m 34s
    UP NEXT
  • Playable
    2. 
    Stack and Heap Memory
    11m 18s
  • Locked
    3. 
    Allocating Memory on the Heap Using malloc()
    8m 4s
  • Locked
    4. 
    Freeing Memory on the Heap Using free()
    11m 2s
  • Locked
    5. 
    Creating Arrays on the Heap
    10m 23s
  • Locked
    6. 
    Returning Heap Pointers from Functions
    9m 49s
  • Locked
    7. 
    Comparing Dangling Memory and Memory Leaks
    10m 5s
  • Locked
    8. 
    Using the calloc() and realloc() Functions
    8m 21s
  • Locked
    9. 
    Creating Pointer Variables in a Struct
    7m 18s
  • Locked
    10. 
    Creating Pointers to Struct Objects
    9m 17s
  • Locked
    11. 
    Course Summary
    3m 52s

EARN A DIGITAL BADGE WHEN YOU COMPLETE THIS COURSE

Skillsoft is providing you the opportunity to earn a digital badge upon successful completion of this course, which can be shared on any social network or business platform

Digital badges are yours to keep, forever.