write a byte to byte string

You're viewing an older version of this page (#3265). View the current version.

View versions (3)

NAME

memset

INTERFACE

#include <string.h> void memset ( void *b, int c, size_t len )

DESCRIPTION

The memset() function writes len bytes of value c (converted to an unsigned char) to the string b.

Example 1

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

int main()
{
  char *s;
  s=(char*) malloc(20);
  memset(s,'\0',20);
  printf("\nString contains:%s", s);

  memset(s,'a',5);
  printf("\nNew String contains:%s",s);
  
  return 0;
}

RETURN VALUES

The memset function returns its first argument.

Compatibility

<table class="compat"> <tr><th></th><th>DOS</th><th>UNIX</th><th>Windows</th><th>ANSI C</th><th>C++ only</th></tr> <tr><td>memset</td><td>&bull;</td><td>&bull;</td><td>&bull;</td><td>&bull;</td><td></td></tr> </table>

SEE ALSO

swab, memcpy