-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_calloc.c
35 lines (32 loc) · 1.33 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_calloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gudaniel <gudaniel@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/09 13:55:10 by gudaniel #+# #+# */
/* Updated: 2024/04/22 19:57:37 by gudaniel ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_calloc(size_t nmemb, size_t size)
{
void *ptr;
ptr = (void *) malloc(nmemb * size);
if (ptr == NULL)
return (NULL);
ft_bzero(ptr, nmemb * size);
return (ptr);
}
/* int main()
{
char *str;
str = (char *) ft_calloc(-15, 15);
strcpy(str, "Gustavo");
printf("String: %s, Address: %p\n", str, str);
str = (char *) ft_calloc(15, sizeof(char));
strcpy(str, "Gustavo");
printf("String: %s, Address: %p\n", str, str);
return (0);
} */