From the course: Master C Language Pointers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Managing memory - C Tutorial
From the course: Master C Language Pointers
Managing memory
- [Instructor] The memcpy and memmove functions are defined in the string.h header file. They copy or move a chunk of memory, raw bytes, from one buffer to another. Now they're considered string functions because they work with bytes or size_t values. These functions manipulate memory. The memory location and address, or pointer, or the name of an array, is used as the source or destination. But the memory contents are copied or moved, unlike just assigning an address to a pointer. In this code, the memcpy function of line 11, copies of the contents of array a, declared here at line seven, into array b, which is declared empty at line eight. Build and run. And you see that the array was duplicated. The memove function can move memory between overlapping locations, so at line seven, a five element array is declared. The memmove function at line 10, copies from the base of array a, which is the second argument, into…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Understanding pointers to pointers4m 32s
-
(Locked)
Sending a pointer to a function3m 36s
-
(Locked)
Sorting pointers2m 6s
-
(Locked)
Managing memory3m 56s
-
(Locked)
Creating pointers to functions2m 30s
-
(Locked)
Challenge: Manipulate a pointer array1m 18s
-
(Locked)
Solution: Manipulate a pointer array3m 20s
-
(Locked)