enleve strnew dans itoa
This commit is contained in:
BIN
.Makefile.swn
BIN
.Makefile.swn
Binary file not shown.
18
Makefile
18
Makefile
@@ -55,15 +55,15 @@ SRCS = ft_memset.c \
|
|||||||
ODIR = ./builds
|
ODIR = ./builds
|
||||||
OBJS = $(SRCS:%.c=$(ODIR)/%.o)
|
OBJS = $(SRCS:%.c=$(ODIR)/%.o)
|
||||||
|
|
||||||
SRCB = ft_lstnew.c \ #fonction un peu changee
|
SRCB = ft_lstnew.c \
|
||||||
ft_lstadd.c \ #ft_lstadd_front.c
|
ft_lstadd.c \
|
||||||
ft_lstsize \ #a creer
|
ft_lstsize \
|
||||||
ft_lstlast \ #a creer
|
ft_lstlast \
|
||||||
ft_lstadd_back \ #a creer
|
ft_lstadd_back \
|
||||||
ft_lstdelone.c \ #fonction un peu changee
|
ft_lstdelone.c \
|
||||||
ft_lstdel.c \ #lstclear et un peu changee
|
ft_lstdel.c \
|
||||||
ft_lstiter.c \ #fonction un peu changee
|
ft_lstiter.c \
|
||||||
ft_lstmap.c \ #fonction un peu changee
|
ft_lstmap.c \
|
||||||
\
|
\
|
||||||
ft_strcat.c \
|
ft_strcat.c \
|
||||||
ft_strcmp.c \
|
ft_strcmp.c \
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2018/11/14 21:19:08 by hulamy #+# #+# */
|
/* 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
BIN
srcs/bonus/.DS_Store
vendored
Binary file not shown.
BIN
srcs/bonus/a.out
BIN
srcs/bonus/a.out
Binary file not shown.
@@ -115,6 +115,7 @@ t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
|
|||||||
lst = lst->next;
|
lst = lst->next;
|
||||||
if (!(tmp->next = (t_list*)f(lst)))
|
if (!(tmp->next = (t_list*)f(lst)))
|
||||||
{
|
{
|
||||||
|
del(tmp->next->content);
|
||||||
free(tmp->next);
|
free(tmp->next);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
srcs/part2/a.out
Executable file
BIN
srcs/part2/a.out
Executable file
Binary file not shown.
@@ -6,11 +6,30 @@
|
|||||||
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2018/11/14 21:10:25 by hulamy #+# #+# */
|
/* 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)
|
char *ft_itoa(int n)
|
||||||
{
|
{
|
||||||
@@ -24,8 +43,9 @@ char *ft_itoa(int n)
|
|||||||
len++;
|
len++;
|
||||||
nbis = n;
|
nbis = n;
|
||||||
nbis *= (nbis < 0) ? -1 : 1;
|
nbis *= (nbis < 0) ? -1 : 1;
|
||||||
if (!(str = ft_strnew(len)))
|
if (!(str = (char *)malloc(sizeof(char) * (len + 1))))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
str[len] = '\0';
|
||||||
str[--len] = nbis % 10 + '0';
|
str[--len] = nbis % 10 + '0';
|
||||||
while (nbis /= 10)
|
while (nbis /= 10)
|
||||||
str[--len] = nbis % 10 + '0';
|
str[--len] = nbis % 10 + '0';
|
||||||
|
|||||||
Reference in New Issue
Block a user