Namespaces
Variants
Views
Actions

memset

From cppreference.com
< c‎ | string‎ | byte
Revision as of 22:18, 25 September 2013 by Eendy (Talk | contribs)

Defined in header <string.h>
void* memset( void* dest, int ch, size_t count );

Converts the value ch to unsigned char and copies it into each of the first count characters of the object pointed to by dest.

Contents

Parameters

dest - pointer to the object to fill
ch - fill byte
count - number of bytes to fill

Return value

dest

Example

#include <stdio.h>
#include <string.h>
 
int main ()
{
    char str[] = "ghghghghghghghghghghgh";
    puts(str);
    memset(str,'a',5);
    puts(str);
    return 0;
}

Output:

ghghghghghghghghghghgh
aaaaahghghghghghghghgh

See also

copies one buffer to another
(function) [edit]