-Subproject commit f56fd060021c191397b4bbb600d5e9f4f1203fee
+Subproject commit b1a54dd5836019e70a715e04420298092def5f3e
/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/05 11:30:56 by ljiriste #+# #+# */
-/* Updated: 2023/09/08 17:52:41 by ljiriste ### ########.fr */
+/* Updated: 2023/09/11 12:41:51 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
res = ft_strdup(va_arg(*args, char *));
else if (type == 'p')
res = ft_itoa_base((intptr_t)va_arg(*args, void *), "0123456789abcdef");
- if (type == 'p' && ft_strncmp(res, "0", 2) == 0)
- {
- free (res);
- res = ft_strdup("(nil)");
- }
return (res);
}
/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/05 11:28:21 by ljiriste #+# #+# */
-/* Updated: 2023/09/08 16:39:07 by ljiriste ### ########.fr */
+/* Updated: 2023/09/11 12:42:41 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
-#include <stddef.h> // NULL
+#include <stdlib.h> // NULL, free
#include <limits.h>
#include "libft.h"
#include "ft_printf.h"
{
t_to_print res;
+ if ((conv.type == 'p' && ft_strncmp(str, "0", 2) == 0))
+ {
+ free (str);
+ str = ft_strdup("(nil)");
+ }
+ else if (conv.type == 's' && str == NULL)
+ str = ft_strdup("(null)");
init_printed(&res);
create_main(str, &res, conv);
create_alt(&res, conv);
/* By: ljiriste <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/06 17:26:17 by ljiriste #+# #+# */
-/* Updated: 2023/09/08 17:58:29 by ljiriste ### ########.fr */
+/* Updated: 2023/09/11 12:32:32 by ljiriste ### ########.fr */
/* */
/* ************************************************************************** */
i += ft_printf("\t%s\n", "Hello");
i += ft_printf("\t%.31s\n", "This is a not a very long text. Because this second part is not printed.");
- char *s;
+ char *s = NULL;
+ i += ft_printf("Asd%s\n", s);
+
s = ft_strdup("The end.");
i += ft_printf("\t%s%*s\n", "The end is 20 spaces away", ft_strlen(s) + 20, s);
free(s);