COHERENT manpages

This page displays the COHERENT manpage for memset() [Fill an area with a character].

List of available manpages
Index


memset() -- String Function (libc)

Fill an area with a character
#include <string.h>
char *memset(buffer, character, n)
char *buffer; int character; unsigned int n;

memset() fills  the first  n bytes  of the area  pointed to by  buffer with
copies of character. It casts  character to an unsigned char before filling
buffer with copies of it.

memset() returns the pointer buffer.

Example

The following example fills an area with `X', and prints the result.

#include <stdio.h>
#include <string.h>
#define BUFSIZ 20

main()
{
    char buffer[BUFSIZ];

    /* fill buffer with 'X' */
    memset(buffer, 'X', BUFSIZ);

    /* append null to end of buffer */
    buffer[BUFSIZ-1] = '\0';

    /* print the result */
    printf("%s\n", buffer);
    return(EXIT_SUCCESS);
}

See Also

libc,
string.h
ANSI Standard, §7.11.6.1