Folks, here is an implementation of memset(), however I have been told that there is one logical mistake in the code. Could you help me find it.
I feel that a double pointer for the target string should be passed to this function, which will be like passing the address of the pointer variable and not the pointer itself.
I am getting an "access violation" when I execute the code in MS VC++ IDE.
The definition of the āCā Library function memset is
void *memset(char *s, char c, size_t n)
Copy c to the first n characters of s. Return s.
void *memset(char *s, char c, size_t n)
{
size_t i;
for (i = 0; i < n; i++, s++)
{
*s = c;
}
return s;
}