-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_calloc.c
More file actions
51 lines (43 loc) · 1.49 KB
/
ft_calloc.c
File metadata and controls
51 lines (43 loc) · 1.49 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: marvin <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/19 17:52:03 by marvin #+# #+# */
/* Updated: 2022/05/19 19:08:00 by marvin ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t count, size_t size)
{
size_t tot_size;
void *dest;
tot_size = size * count;
dest = malloc(tot_size);
if (!dest)
return (NULL);
ft_memset(dest, 0, tot_size);
return (dest);
}
/*int main()
{
int i, n;
int *a;
printf("Number of elements to be entered:");
scanf("%d", &n);
a = (int *)ft_calloc(n, sizeof(int));
printf("Enter %d numbers:\n", n);
for (i = 0; i < n; i++)
{
scanf("%d", &a[i]);
}
printf("The numbers entered are: ");
for (i = 0; i < n; i++)
{
printf("%d ", a[i]);
}
free(a);
return (0);
}*/