C memset() Function

Last Updated:

C memset()

The memset() function replaces every character of a string with the symbol given by the programmer up to the specified length.

Example

C Compiler
#include <stdio.h> #include <string.h> int main() { char mail[] = "johndoe@gmail.com"; memset(mail, '*', 4); printf("Your email id: %s", mail); return 0; }

Syntax

void *memset(void *str, int ch, size_t n)

Parameter Values

ValueTypeExplanation
str Required Specifies a string.
ch Required Specifies a character by which the string is to be replaced.
n Required Specifies the number of characters to be replaced.

Return Value

ValueExplanation
Address Returns a pointer to the memory area str.

Share this Page

Meet the Author