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 coursecontrast stack and heap memoryuse malloc() to allocate memory on the heapuse the free() method to free stack memory that is not allocatedallocate space for arrays using malloc()return pointers to heap locations from functions
-
distinguish between dangling memory and memory leakscontrast malloc(), calloc(), and realloc()create pointers on struct objectscreate pointer fields in structssummarize the key concepts covered in this course
IN THIS COURSE
-
1.Course Overview2m 34sUP NEXT
-
2.Stack and Heap Memory11m 18s
-
3.Allocating Memory on the Heap Using malloc()8m 4s
-
4.Freeing Memory on the Heap Using free()11m 2s
-
5.Creating Arrays on the Heap10m 23s
-
6.Returning Heap Pointers from Functions9m 49s
-
7.Comparing Dangling Memory and Memory Leaks10m 5s
-
8.Using the calloc() and realloc() Functions8m 21s
-
9.Creating Pointer Variables in a Struct7m 18s
-
10.Creating Pointers to Struct Objects9m 17s
-
11.Course Summary3m 52s
EARN A DIGITAL BADGE WHEN YOU COMPLETE THIS COURSE
Skillsoft is providing you the opportunity to earn a digital badge upon successful completion on some of our courses, which can be shared on any social network or business platform.
Digital badges are yours to keep, forever.