.TH memset() "" "" "String Function (libc)"
.PC "Fill an area with a character"
.B "#include <string.h>"
\fBchar *memset(\fIbuffer\^\fB, \fIcharacter\^\fB, \fIn\^\fB)\fR
\fBchar *\fIbuffer\^\fB; int \fIcharacter\^\fB; unsigned int \fIn\^\fB;\fR
.PP
.II "fill an area with a character"
.II "character, fill an area with"
.B memset()
fills the first
.I n
bytes of the area pointed to by
.I buffer
with copies of
.IR character .
It casts
.I character
to an \fBunsigned char\fR before filling
.I buffer
with copies of it.
.PP
.B memset()
returns the pointer
.IR buffer .
.SH Example
The following example fills an area with \*(QlX\*(Qr, and prints the
result.
.DM
#include <stdio.h>
#include <string.h>
#define BUFSIZ 20
.DE
.DM
main()
{
	char buffer[BUFSIZ];
.DE
.DM
	/* fill buffer with 'X' */
	memset(buffer, 'X', BUFSIZ);
.DE
.DM
	/* append null to end of buffer */
	buffer[BUFSIZ-1] = '\e0';
.DE
.DM
	/* print the result */
	printf("%s\en", buffer);
	return(EXIT_SUCCESS);
}
.DE
.SH "See Also"
.Xr "libc," libc
.Xr "string.h" string.h
.br
\*(AS, \(sc7.11.6.1
