New Generic pointer that can point to any data type
1st Parameter
Pointer to the memory block to be filled.
2nd Parameter Type : int
Integer type (typically 4 bytes, -2,147,483,648 to 2,147,483,647)
2nd Parameter
The value to be set, converted to an `unsigned char` and used to fill the memory block.
3rd Parameter Type : size_t
Platform-specific unsigned type for array indices and memory sizes.
3rd Parameter
The number of bytes to fill in the memory block.
Read more about parameters of memset in parameters section
The memsetfunction in C language Fills a block of memory with a specified value.
The memset function fills the first n bytes of the memory area pointed to by s with the constant byte c. It is often used to initialize or reset memory blocks to a specific value.
The memsetfunction takes 3
parameters:
•
void * `ptr`: Pointer to the memory block to be filled.
•
int `value`: The value to be set, converted to an `unsigned char` and used to fill the memory block.
•
size_t `num`: The number of bytes to fill in the memory block.
Fills the first `num` bytes of the memory block pointed to by `ptr` with the constant byte value `value`. Returns a pointer to the memory block `ptr`.
The memset function return value :
Returns a pointer to the memory area s
Output
This example demonstrates basic usage of memset to initialize a character array with dashes.