-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_bzero.c
45 lines (41 loc) · 1.43 KB
/
ft_bzero.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
41
42
43
44
45
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_bzero.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: luiroel <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/03 04:29:50 by luiroel #+# #+# */
/* Updated: 2020/02/26 21:17:43 by luiroel ### ########.fr */
/* */
/* ************************************************************************** */
/*
** We can't work with void *s directly
** so first we need to create our intermidiary
** and then work with that. You'll also notice
** we're using a counter of type size_t, meaning
** our size in bytes. If the fed in size is 0
** we do nothing, otherwise while our counter
** is less than the size, we keep writing nulls
** until we've zeroed out the entire *s indirectly
*/
#include "libft.h"
void ft_bzero(void *s, size_t n)
{
char *str;
size_t i;
i = 0;
str = s;
if (n == 0)
{
return ;
}
else
{
while (i < n)
{
str[i] = '\0';
i++;
}
}
}