Set buffers to a specified character.
#include <memory.h> | Required only for function declarations | |
#include <string.h> | Use either STRING.H (for ANSI compatibility) or MEMORY.H |
void *memset( void *dest, int c, size_t count );
void __far * __far _fmemset( void __far *dest, int c, size_t count );
dest | Pointer to destination | |
c | Character to set | |
count | Number of characters |
The memset and _fmemset functions set the first count bytes of dest to the character c.
The _fmemset function is a model-independent (large-model) form of the memset function. It can be called from any point in any program.
There is a semantic difference between the function version of memset and its intrinsic version. The function version supports huge pointers in compact-, large-, and huge-model programs, but the intrinsic version does not.
The memset and _fmemset functions return the value of dest.
memset
Standards:ANSI, UNIX
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:DOS32X
_fmemset
Standards:None
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:None
_memccpy, memchr, memcmp, memcpy, _strnset
/* 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 );
}
Before: This is a test of the memset function
After: **** is a test of the memset function