Re: Doubt in memcpy() and memset()




Dead Loop wrote:
Chris Dollin wrote:

memset( void *s, int c, size_t n );

... copies the value of c (converted to an unsigned char)
into each of the first n characters of the object pointed
to by s.


By the way, I'm puzzled about the type of the second parameter.
Why not use (unsigned char) type?
memset(void *s, unsigned char c, size_t n);

Backwards compatibility.

Both memcpy() and memset() were defined back in the day of K&R C. In
the K&R C definition, char was automatically promoted to int when used
as a function argument.

.



Relevant Pages