enleve strnew dans itoa

This commit is contained in:
Hugo LAMY
2019-11-25 11:58:15 +01:00
parent e240d38318
commit c29be1b311
8 changed files with 34 additions and 13 deletions

Binary file not shown.

View File

@@ -55,15 +55,15 @@ SRCS = ft_memset.c \
ODIR = ./builds
OBJS = $(SRCS:%.c=$(ODIR)/%.o)
SRCB = ft_lstnew.c \ #fonction un peu changee
ft_lstadd.c \ #ft_lstadd_front.c
ft_lstsize \ #a creer
ft_lstlast \ #a creer
ft_lstadd_back \ #a creer
ft_lstdelone.c \ #fonction un peu changee
ft_lstdel.c \ #lstclear et un peu changee
ft_lstiter.c \ #fonction un peu changee
ft_lstmap.c \ #fonction un peu changee
SRCB = ft_lstnew.c \
ft_lstadd.c \
ft_lstsize \
ft_lstlast \
ft_lstadd_back \
ft_lstdelone.c \
ft_lstdel.c \
ft_lstiter.c \
ft_lstmap.c \
\
ft_strcat.c \
ft_strcmp.c \

View File

@@ -6,7 +6,7 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/14 21:19:08 by hulamy #+# #+# */
/* Updated: 2019/03/25 15:25:38 by hulamy ### ########.fr */
/* Updated: 2019/11/21 17:00:30 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */

BIN
srcs/bonus/.DS_Store vendored

Binary file not shown.

Binary file not shown.

View File

@@ -115,6 +115,7 @@ t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
lst = lst->next;
if (!(tmp->next = (t_list*)f(lst)))
{
del(tmp->next->content);
free(tmp->next);
return (NULL);
}

BIN
srcs/part2/a.out Executable file

Binary file not shown.

View File

@@ -6,11 +6,30 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/14 21:10:25 by hulamy #+# #+# */
/* Updated: 2018/11/14 21:36:38 by hulamy ### ########.fr */
/* Updated: 2019/11/25 11:57:23 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
** take an integer and give a string
*/
/*
** #include <libc.h>
**
** char *ft_itoa(int n)
**
** int main(int ac, char **av)
** {
** if (ac == 2)
** {
** printf("%s\n",ft_itoa(atoi(av[1])));
** }
** return 0;
** }
**
** #include "libft.h"
*/
char *ft_itoa(int n)
{
@@ -24,8 +43,9 @@ char *ft_itoa(int n)
len++;
nbis = n;
nbis *= (nbis < 0) ? -1 : 1;
if (!(str = ft_strnew(len)))
if (!(str = (char *)malloc(sizeof(char) * (len + 1))))
return (NULL);
str[len] = '\0';
str[--len] = nbis % 10 + '0';
while (nbis /= 10)
str[--len] = nbis % 10 + '0';