-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memset.c
36 lines (32 loc) · 1.23 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
35
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kakiba <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/12 00:06:20 by kakiba #+# #+# */
/* Updated: 2022/07/24 19:50:24 by kakiba ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memset(void *buf, int ch, size_t n)
{
size_t i;
unsigned char *m;
unsigned char c;
c = (unsigned char)ch;
m = (unsigned char *)buf;
i = 0;
while (i < n)
m[i++] = c;
return (m);
}
/*int main()
{
void *s = malloc(2*2);
printf("%p\n", s);
printf("%p\n", memset(s, 'a', 1));
printf("%p\n", ft_memset(s, 'a', 1));
free(s);
}*/