-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_bzero.c
39 lines (36 loc) · 1.64 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_bzero.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmaurer <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/18 12:31:47 by mmaurer #+# #+# */
/* Updated: 2021/09/07 21:42:50 by mmaurer ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/* The bzero() function erases the data in the n bytes of the memory
* starting at the location pointed to by s, by writing zeros (bytes containing
* '\0') to that area.
1. The ft_bzero() function takes two arguments: a void pointer to the memory
area to be modified and the size of the memory area.
2. The ft_bzero() function first stores the address of the memory area in a
char pointer.
3. The while loop runs as long as n is greater than 0.
4. The *cptr pointer is incremented by 1 and n is decremented by 1.
5. The *cptr pointer is set to '\0' and the memory location pointed to by cptr
is set to '\0'.
6. The ft_bzero() function returns nothing.
*/
void ft_bzero(void *s, size_t n)
{
char *cptr;
cptr = s;
while (n)
{
*cptr = '\0';
cptr++;
n--;
}
}