#include <stdlib.h> void *memset(void *str, int c, size_t n);
memset Fill / overwrite memory region with certain characters
str = Target memory block /c string
c = value byte that is used to overwrite
n = number of chars to be copied
/* * memset example code * http://code-reference.com/c/string.h/memset */ #include <stdio.h> #include <string.h> int main(void) { char string[15] = "memset example"; int i; for (i=0;i<=15;i++) { memset(string ,'*', i); printf("%s\n",string); } return 0; }
user@host:~/code-reference.com# ./memset memset example *emset example **mset example ***set example ****et example *****t example ****** example *******example ********xample *********ample **********mple ***********ple ************le *************e ************** ***************