memset : memset « string.h « C Tutorial






ItemValue
Header filestring.h
Declarationvoid *memset(void *buf, int ch, size_t count);
Functioncopies ch into the first count characters of *buf.
Returnreturns buf.


The most common use of memset() is to initialize a region of memory to some value.

#include <string.h>
#include <stdio.h>

int main(void){
  char buf[100];
  memset(buf, '\0', 100);
  memset(buf, 'X', 10);
  printf(buf);
}
XXXXXXXXXX








24.5.memset
24.5.1.memset