memset
Sets buffers to a specified character.
Routine | Required Header |
---|---|
memset | <memory.h> or <string.h> |
void *memset( void *dest, int c, size_t count );
Parameters
-
dest
- Pointer to destination c
- Character to set count
- Number of characters
Libraries
All versions of the C run-time libraries.
Return Values
memset returns the value of dest.
Remarks
The memset function sets the first count bytes of dest to the character c.
Example
/* MEMSET.C: This program uses memset to * set the first four bytes of buffer to "*". */ #include <memory.h> #include <stdio.h> void main( void ) { char buffer[] = "This is a test of the memset function"; printf( "Before: %s/n", buffer ); memset( buffer, '*', 4 ); printf( "After: %s/n", buffer ); }
Output
Before: This is a test of the memset function After: **** is a test of the memset function