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

Managing memory - C Tutorial

From the course: Master C Language Pointers

Start my 1-month free trial

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…

Contents