-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_calloc.c
36 lines (33 loc) · 1.17 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
/* ************************************************************************** */
/* */
/* :::::::: */
/* calloc.c :+: :+: */
/* +:+ */
/* By: ivan-mel <[email protected]> +#+ */
/* +#+ */
/* Created: 2022/10/11 12:38:19 by ivan-mel #+# #+# */
/* Updated: 2022/10/11 16:14:38 by ivan-mel ######## odam.nl */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <stdlib.h>
void *ft_calloc(size_t count, size_t size)
{
char *ptr;
size_t i;
ptr = malloc(count * size);
i = 0;
if (ptr == NULL)
return (ptr);
while (i < (count * size))
{
ptr[i] = 0;
i++;
}
return ((void *)ptr);
}
/*
int main(void)
{
ft_calloc(5, 4);
}*/