-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memset.c
38 lines (34 loc) · 1.25 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
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ibeliaie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/16 13:31:43 by ibeliaie #+# #+# */
/* Updated: 2023/05/23 13:59:00 by ibeliaie ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/* fill block of memory */
void *ft_memset(void *b, int c, size_t len)
{
unsigned char *ptr;
unsigned char val;
size_t i;
i = 0;
ptr = (unsigned char *)b;
val = (unsigned char)c;
while (i < len)
{
ptr[i] = val;
i++;
}
return (b);
}
// int main()
// {
// char str[7] = "bonjour";
// ft_memset(str, '!' , 4);
// printf("Modified string: %s\n", str);
// }