-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memset.c
40 lines (34 loc) · 1.21 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
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: xle-boul <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/10 21:42:03 by xle-boul #+# #+# */
/* Updated: 2021/10/11 11:14:13 by xle-boul ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/* sets the n first elements of a string to a given char */
void *ft_memset(void *s, int c, size_t n)
{
unsigned char *str;
str = (unsigned char *)s;
while (n)
{
*str = (const char)c;
str++;
n--;
}
return (s);
}
/*
int main()
{
char s[] = "blablabla";
ft_memset(s, 'A', 5);
printf("%s\n", s);
return 0;
}
*/