memset - C string.h

C examples for string.h:memset

Type

function

From

<cstring> 
<string.h>

Description

Fill block of memory

Prototype

void* memset (void* ptr, int value, size_t num );

Parameters

Parameter Description
ptr Pointer to the block of memory to fill.
value Value to be set.
num Number of bytes to be set.

Return Value

ptr is returned.

Demo Code


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

int main ()//from ww w  .  j av  a2s.c o m
{
  char str[] = "this is a test! this is a test test test test.";
  memset (str,'-',6);
  puts (str);
  return 0;
}

Related Tutorials