TOC | Prev | Next

void *memset( void *target, int c, size_t bytes )

Sets memory to a given character value. Usually for blanking big
chunks of fresh memory.

int *scores = malloc( 100 * sizeof( int ) );
memset( scores, 0, 100 * sizeof( int ) );

What it does:

void *memset( void *target, int c, size_t bytes )
{
    char *p = target;

    while ( bytes-- ) {
        *p++ = c;
    }
    return target;
}
TOC | Prev | Next