enleve strnew dans itoa
This commit is contained in:
@@ -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
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;
|
||||
if (!(tmp->next = (t_list*)f(lst)))
|
||||
{
|
||||
del(tmp->next->content);
|
||||
free(tmp->next);
|
||||
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> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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';
|
||||
|
||||
Reference in New Issue
Block a user