diff --git a/ft_printf b/ft_printf index 6b6598d..efe1a21 100755 Binary files a/ft_printf and b/ft_printf differ diff --git a/ft_printf.h b/ft_printf.h index de62644..f0c7d3f 100644 --- a/ft_printf.h +++ b/ft_printf.h @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_printf.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/27 12:07:47 by hulamy #+# #+# */ +/* Updated: 2020/02/27 12:08:40 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + #ifndef FT_PRINTF_H # define FT_PRINTF_H # include @@ -7,24 +19,36 @@ # include -// ft_printf.c +/* +** ft_printf.c +*/ + char *specifier(char *s); int ft_expand_star(int nbr, char **string); int ft_put_word(char *s, char *type); int length_n_free(int length, char *s); int ft_printf(char *string, ...); -// ft_next_word.c +/* +** ft_next_word.c +*/ + int width_precision(char *s); int word_length(char *s); char *next_word(char **s); -// ft_convert.c +/* +** ft_convert.c +*/ + char *conv_i(char c, long int i); char *conv_u(char c, unsigned long int i); char *ft_convert(va_list ap, char *type); -// ft_flag_transform.c +/* +** ft_flag_transform.c +*/ + char *precision_int(char *print, int precision); char *ft_precision(char *s, char *print, char *type); char *width_flags(char *print, char *tmp, char *s, int width); diff --git a/out1.txt b/out1.txt deleted file mode 100644 index e69de29..0000000 diff --git a/out2.txt b/out2.txt deleted file mode 100644 index 11afd15..0000000 --- a/out2.txt +++ /dev/null @@ -1,2 +0,0 @@ -printf2:test1 -printf2:test2 diff --git a/srcs/ft_convert.c b/srcs/ft_convert.c index ee2c697..6013994 100644 --- a/srcs/ft_convert.c +++ b/srcs/ft_convert.c @@ -1,10 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_convert.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/27 12:03:28 by hulamy #+# #+# */ +/* Updated: 2020/02/27 12:03:38 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ #include "ft_printf.h" /* ** FT_CONVERT : ** -convert the next argument into a string according to the following -** correspondances for diuxXcspefgn : +** correspondances for diuxXcspefgn : ** [char] [hhd, hhi, c] [int] [d i c] ** [short] [hd, hi] [int] ** [int] [d, i] [int] @@ -73,7 +84,7 @@ char *ft_convert(va_list ap, char *type) if ((s = ft_strchrset(type, "s"))) return (conv_u(s[0], va_arg(ap, unsigned long int))); if (ft_strchr(type, '%')) - return(ft_strdup("%")); + return (ft_strdup("%")); if (ft_strchrset(type, "efgn")) return (NULL); return (NULL); diff --git a/srcs/ft_flag_transform.c b/srcs/ft_flag_transform.c index 3258cb5..6036ffa 100644 --- a/srcs/ft_flag_transform.c +++ b/srcs/ft_flag_transform.c @@ -6,7 +6,7 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/27 11:55:43 by hulamy #+# #+# */ -/* Updated: 2020/02/27 11:55:45 by hulamy ### ########.fr */ +/* Updated: 2020/02/27 12:07:22 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -57,7 +57,7 @@ char *precision_int(char *print, int precision) ** -if flag '0' is present in %string, removes it (actually turn each occurence ** in a '.') ** -and transform 'print' according to the precision : -** -0 if .precision == 0 and print == "0": return (print[0] = '\0') (print nothing) +** -0 if .precision is 0 && print is "0": print nothing ** -1 if type is s: if length(s) > precision, removes end of 'print' to print ** only x chars, with x = precision ** -2 if type is "diouxX": call fonction 'precision_int' that return : @@ -119,7 +119,7 @@ char *width_flags(char *print, char *tmp, char *s, int width) } else { - c = (ft_strchr(s, '0')) ? '0' : ' ' ; + c = (ft_strchr(s, '0')) ? '0' : ' '; while (i < (width - ft_strlen(print))) tmp[i++] = c; while (print[j]) @@ -154,7 +154,6 @@ char *ft_width(char *s, char *print) return (print); } - /* ** go through all the transformation flags needs */