ft_memset

Subject

MEMSET(3) (simplified)

NAME
    memset -- fill a byte string with a byte value
SYNOPSIS
    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.
RETURN VALUES
    The memset() function returns its first argument.

Understandable explanation

As the man description says, this function writes len bytes of value c to the string b.

The value of c will be converted to an unsigned char, so to set this value in the b string, we'll have to convert the b string to a pointer to unsigned char. But remember the return value, we have to return the first parameter of the function, the void *b string.

So how do we convert this parameter without changing the original one ? Think about temporary variables.

Hints

To build this function, we'll have to declare a temporary variable, an unsigned char *. We'll then make all our manipulation on this pointer, without touching the original void *b string.

Commented solution

ft_memset

Last updated

Was this helpful?