This commit is contained in:
Jeremy FLEURY
2019-07-17 11:51:13 +02:00
parent 748d10f4f3
commit 45e980b4e3
65 changed files with 6601 additions and 18 deletions

View File

@@ -6,7 +6,7 @@
/* By: jfleury <jfleury@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/01/23 15:05:04 by allefebv #+# #+# */
/* Updated: 2019/07/09 15:26:17 by jfleury ### ########.fr */
/* Updated: 2019/07/17 11:39:51 by jfleury ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,7 +14,7 @@
#include <stdlib.h>
#include <string.h>
static int ft_malloc_len(unsigned int nb, int base)
static int ft_malloc_len(unsigned int nb, int base)
{
int i;
@@ -27,11 +27,11 @@ static int ft_malloc_len(unsigned int nb, int base)
return (i);
}
char *ft_itoa_base_int(unsigned int nb, int base)
unsigned char *ft_itoa_base_int(unsigned int nb, int base)
{
unsigned int result;
int i;
char *str;
unsigned char *str;
char *tab;
tab = ft_strdup("0123456789abcdef");
@@ -40,7 +40,7 @@ char *ft_itoa_base_int(unsigned int nb, int base)
i = ft_malloc_len(nb, base);
if (nb == 0)
i++;
if (!(str = (char*)malloc(sizeof(char*) * i + 1)))
if (!(str = malloc(sizeof(unsigned char*) * i + 1)))
return (NULL);
str[i] = '\0';
if (nb == 0)

View File

@@ -6,7 +6,7 @@
/* By: jfleury <jfleury@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/01/23 15:05:04 by allefebv #+# #+# */
/* Updated: 2019/07/13 17:27:38 by tmaze ### ########.fr */
/* Updated: 2019/07/17 11:40:00 by jfleury ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,9 +14,9 @@
#include <stdlib.h>
#include <string.h>
static int ft_malloc_len(unsigned short nb, int base)
static int ft_malloc_len(unsigned short nb, int base)
{
short i;
short i;
i = 0;
while (nb != 0)
@@ -27,12 +27,12 @@ static int ft_malloc_len(unsigned short nb, int base)
return (i);
}
char *ft_itoa_base_short(unsigned short nb, int base)
unsigned char *ft_itoa_base_short(unsigned short nb, int base)
{
unsigned short result;
short i;
char *str;
char *tab;
unsigned short result;
short i;
unsigned char *str;
char *tab;
tab = ft_strdup("0123456789abcdef");
if (base < 2 || base > 16)
@@ -40,7 +40,7 @@ char *ft_itoa_base_short(unsigned short nb, int base)
i = ft_malloc_len(nb, base);
if (nb == 0)
i++;
if (!(str = (char*)malloc(sizeof(char*) * i + 1)))
if (!(str = malloc(sizeof(unsigned char*) * i + 1)))
return (NULL);
str[i] = '\0';
if (nb == 0)