On this page
  1. memset
  2. Include
  3. Signature & Overview
  4. Notes & Pitfalls
  5. Example

memset

Prev: memmove | Up: string.h | Next: memcmp
Rel: string.h, stdlib.h & string.h Guide
Ref: cppreference — memset
Tags: #public #prog #c #stdlib #string #tier/core


Include

#include <string.h>

Signature & Overview

void *memset(void *dst, int ch, size_t n);

Fills n bytes starting at dst with (unsigned char)ch.

Notes & Pitfalls

Example

#include <assert.h>
#include <string.h>

int main(void) {
    int arr[4];
    memset(arr, 0, sizeof(arr));
    assert(arr[0] == 0 && arr[3] == 0);
}

Linked from

Related notes