RAD Studio |  |

memset, _wmemset

Header File

mem.h, string.h

Category

Memory and String Manipulation Routines, Inline Routines

Prototype

void *memset(void *s, int c, size_t n);

void *_wmemset(void *s, int c, size_t n);

Description

Sets n bytes of a block of memory to byte c.

memset sets the first n bytes of the array s to the character c.

Return Value

memset returns s.

Example

Copy Code

    #include <string.h>
    #include <stdio.h>
    #include <mem.h>
    int main(void)
    {
        char buffer[] = "Hello world\n";
        printf("Buffer before memset: %s\n", buffer);
        memset(buffer, '*', strlen(buffer) - 1);
        printf("Buffer after memset:  %s\n", buffer);
        return 0;
    }

Portability

| POSIX | Win32 | ANSI C | ANSI C++
memset | + | + | + | +
_wmemset |  | + |  |

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!