To set all the bytes in a block of memory to a particular value, use memset(). The function prototype is
void * memset(void *dest, int c, size_t count);
The argument dest points to the block of memory. c is the value to set, and count is the number of bytes, starting at dest, to be set. Note that while c is a type int, it is treated as a type char. In other words, only the low-order byte is used, and you can specify values of c only in the range 0 through 255.
Example
/* memset example */
#include
#include
int main ()
{
char str[] = "almost every programmer should know memset!";
memset (str,'-',6);
puts (str);
return 0;
}
Output:
------ every programmer should know memset!