C++ Programming/Code/Standard C Library/Functions/memset

memset
The function memset copies ch into the first count characters of buffer, and returns buffer. memset is useful for intializing a section of memory to some value. For example, this command:

...is a very efficient way to set all values of the_array to zero.

The table below compares two different methods for initializing an array of characters: a loop versus memset. As the size of the data being initialized increases, memset clearly gets the job done much more quickly:


 * Related topics: memcmp - memcpy - memmove