-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_bzero.c
80 lines (73 loc) · 2.51 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_bzero.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: edetoh <edetoh@student.42lehavre.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/15 09:39:13 by edetoh #+# #+# */
/* Updated: 2024/10/25 11:08:30 by edetoh ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
* The ft_bzero function fills the first 'n' bytes of the memory
* area pointed to by 'pointer' with zeros.
*
* It takes two arguments: a pointer 'pointer' to the memory area
* to be filled, and a size_t 'count' which is the size of the
* memory area to be filled.
*
* It does not return anything. This function is generally used
* to initialize a memory area to zero.
*/
void ft_bzero(void *s, size_t n)
{
unsigned char *ptr;
size_t i;
ptr = (unsigned char *)s;
i = 0;
while (i < n)
{
ptr[i] = 0;
i++;
}
}
// #include <string.h>
// #include <assert.h>
// #include <stdlib.h>
// #include <stdio.h>
// int main(int argc, char **argv)
// {
// char *str;
// char *str2;
// (void)argv;
// assert(argc == 2);
// printf("Etape 1 : L'appel a un arguments\n");
// str = malloc(50);
// ft_bzero(str, 50);
// str2 = malloc(50);
// memset(str2, 0, 50);
// assert(memcmp(str, str2, 50) == 0);
// printf("Etape 2 : Meme resultat pour un bloc de 50 octets\n");
// str = malloc(100);
// ft_bzero(str, 100);
// str2 = malloc(100);
// memset(str2, 0, 100);
// assert(memcmp(str, str2, 100) == 0);
// printf("Etape 3 : Meme resultat pour un bloc de 100 octets\n");
// str = malloc(200);
// ft_bzero(str, 200);
// str2 = malloc(200);
// memset(str2, 0, 200);
// assert(memcmp(str, str2, 200) == 0);
// printf("Etape 4 : Meme resultat pour un bloc de 200 octets\n");
// str = malloc(500);
// ft_bzero(str, 500);
// str2 = malloc(500);
// memset(str2, 0, 500);
// assert(memcmp(str, str2, 500) == 0);
// printf("Etape 5 : Meme resultat pour un bloc de 500 octets\n");
// printf("=== Test OK === \n");
// return (0);
// }