bzero
--------------
NAME
bzero - memory operations (LEGACY)
SYNOPSIS
#include "<"strings.h">"
void bzero(void *s, size_t n);
DESCRIPTION
The bzero() function shall place n zero-valued bytes in the area pointed to by s.
RETURN VALUE
The bzero() function shall not return a value.
ERRORS
No errors are defined.
===============================================================
memset
-----------------------
NAME
memset - set bytes in memory
SYNOPSIS
#include "<"string.h">"
void *memset(void *s, int c, size_t n);
DESCRIPTION
The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of IEEE Std 1003.1-2001 defers to the ISO C standard.
The memset() function shall copy c (converted to an unsigned char) into each of the first n bytes of the object pointed to by s.
RETURN VALUE
The memset() function shall return s; no return value is reserved to indicate an error.
ERRORS
No errors are defined.
--------------------------------
memset
void * memset ( void * ptr, int value, size_t num );
Fill block of memory
Sets the first num bytes of the block of memory pointed by ptr to the specified value (interpreted as an unsigned char).
Parameters
ptr
Pointer to the block of memory to fill.
value
Value to be set. The value is passed as an int, but the function fills the block of memory using the unsigned char conversion of this value.
num
Number of bytes to be set to the value.
Return Value
ptr is returned.
Example
/* memset example */
#include "<"stdio.h">"
#include "<"string.h">"
int main ()
{
char str[] = "almost every programmer should know memset!";
memset (str,'-',6);
puts (str);
return 0;
}
Output:
------ every programmer should know memset!