-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memset.c
34 lines (30 loc) · 1.4 KB
/
ft_memset.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gubranco <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/10 19:24:31 by gubranco #+# #+# */
/* Updated: 2022/11/14 12:01:37 by gubranco ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memset(void *dest, int c, size_t len)
{
size_t i;
unsigned char *str;
i = 0;
str = (unsigned char *)dest;
while (i < len)
{
str[i] = c;
i++;
}
return (dest);
}
/* The memset() function writes len bytes of value c (converted to an
unsigned char) to the string dest. Undefined behaviour from memset(),
resulting from storage overflow, will occur if len is greater than the
the length of buffer dest. The behaviour is also undefined if dest is an
invalid pointer. It returns its first argument. */