Name

memset - fills memory with a constant byte

Library

libc.lib

Synopsis

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

Detailed description

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

Examples

#include <string.h>
#include <stdio.h>
int main()
{
    char one[50];       
    strcpy(one, "abcdefgh");
    printf("String before memset %s\n",one);
    memset(one+1, 'x', 3);
    printf("String after calling memset first time %s\n",one);          
    memset(one+2, 'y', 0);
    printf("String after calling memset second time %s\n",one);
    return 0;   
}

         

Output

String before memset abcdefgh
String after calling memset first time axxxefgh
String after calling memset second time axxxefgh

         

Return value

The memset function returns its first argument.

See also

bzero, swab

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top