-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_calloc.c
39 lines (35 loc) · 1.24 KB
/
ft_calloc.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_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dalcabre <dalcabre@student.42urduliz.co +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/12 13:00:16 by dalcabre #+# #+# */
/* Updated: 2024/01/12 14:05:42 by dalcabre ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t num_elements, size_t element_size)
{
char *array;
size_t total_size;
size_t i;
i = 0;
total_size = (num_elements * element_size);
array = malloc(total_size);
if (array == NULL)
return (NULL);
while (i < total_size)
{
array[i] = 0;
i++;
}
return (array);
}
/*int main(void)
{
ft_calloc(5, 10);
free()
return (0);
}*/