Memset function is C Programming : string.h
- memset : MEMory SET
- It is used to fill the blocks of memory.
- Sets the first num bytes of the block of memory pointed by ptr to the specified value.
Syntax :
void * memset ( void * ptr, int value, size_t num );
Parameters Passed to the Function Memset :
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.
Live Example :
#include<stdio.h> #include<string.h> int main () { char str[] = "C Programming Language"; memset (str,'-',6); puts (str); return 0; }
Output :
------ramming Language