diff --git a/ft_printf.c b/ft_printf.c index fa7a265..660f555 100644 --- a/ft_printf.c +++ b/ft_printf.c @@ -1,14 +1,3 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_printf.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: hulamy +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/02/27 12:01:26 by hulamy #+# #+# */ -/* Updated: 2020/02/27 12:01:30 by hulamy ### ########.fr */ -/* */ -/* ************************************************************************** */ #include "ft_printf.h" diff --git a/main.c b/main.c index 0b6414b..850caa2 100644 --- a/main.c +++ b/main.c @@ -158,40 +158,41 @@ int main(int ac, char **av) { printf("USAGE:\n"); printf("call ./ft_printf with arguments to launch tests :\n"); - printf("./ft_printf 'man' \n"); - printf("........... 'test' \n"); - printf("........... 'all' \n"); - printf("........... ... 'noflag' \n"); - printf("........... ... '0' \n"); - printf("........... ... '-' \n"); - printf("........... ... 'width' \n"); - printf("........... ... 'precision' \n"); - printf("........... ... '*' \n"); - printf("........... ... 'd' \n"); - printf("........... ... 'i' \n"); - printf("........... ... 'u' \n"); - printf("........... ... 'x' \n"); - printf("........... ... 'X' \n"); - printf("........... ... 'c' \n"); - printf("........... ... 's' \n"); - printf("........... ... 'p' \n"); - printf("........... ... '%%' \n"); - printf("........... ... 'repetition'\n"); - printf("........... 'bonus' \n"); - printf("........... ..... '#' \n"); - printf("........... ..... ''' \n"); - printf("........... ..... ' ' \n"); - printf("........... ..... '+' \n"); - printf("........... ..... 'e' \n"); - printf("........... ..... 'f' \n"); - printf("........... ..... 'g' \n"); - printf("........... ..... 'n' \n"); - printf("........... ..... 'h' \n"); - printf("........... ..... 'hh' \n"); - printf("........... ..... 'l' \n"); - printf("........... ..... 'll' \n"); - printf("........... ..... 'repetition'\n"); - printf("........... 'error' \n"); + printf("./ft_printf 'man' \n"); + printf("........... 'test' \n"); + printf("........... 'special' \n"); + printf("........... 'all' \n"); + printf("........... ... 'noflag' \n"); + printf("........... ... '0' \n"); + printf("........... ... '-' \n"); + printf("........... ... 'width' \n"); + printf("........... ... 'precision' \n"); + printf("........... ... '*' \n"); + printf("........... ... 'd' \n"); + printf("........... ... 'i' \n"); + printf("........... ... 'u' \n"); + printf("........... ... 'x' \n"); + printf("........... ... 'X' \n"); + printf("........... ... 'c' \n"); + printf("........... ... 's' \n"); + printf("........... ... 'p' \n"); + printf("........... ... '%%' \n"); + printf("........... ... 'repetition'\n"); + printf("........... 'bonus' \n"); + printf("........... ..... '#' \n"); + printf("........... ..... ''' \n"); + printf("........... ..... ' ' \n"); + printf("........... ..... '+' \n"); + printf("........... ..... 'e' \n"); + printf("........... ..... 'f' \n"); + printf("........... ..... 'g' \n"); + printf("........... ..... 'n' \n"); + printf("........... ..... 'h' \n"); + printf("........... ..... 'hh' \n"); + printf("........... ..... 'l' \n"); + printf("........... ..... 'll' \n"); + printf("........... ..... 'repetition'\n"); + printf("........... 'error' \n"); } if (ac == 2 && !strcmp(av[1], "man")) @@ -275,7 +276,12 @@ int main(int ac, char **av) if (ac == 2 && !strcmp(av[1], "special")) { - PRINT("\\!/%16c\\!/", (char)0) + PRINT("%16c", (char)0) + PRINT("%-16c", (char)0) + PRINT("%16c", 'a') + PRINT("%-16c", 'a') + PRINT("%16c", (char)7) + PRINT("!%37c!", (char)0) } /* ////////////////////////////////////////////////////////////////// */ @@ -356,6 +362,8 @@ int main(int ac, char **av) PRINT("%0i", 0); PRINT("%6i", -456); PRINT("%6%"); + PRINT("%16c", 'a'); + PRINT("%16c", (char)97); } if (ac == 2 || !strcmp(av[2], "precision")) diff --git a/outf.txt b/outf.txt new file mode 100644 index 0000000..275e73e Binary files /dev/null and b/outf.txt differ diff --git a/outft.txt b/outft.txt new file mode 100644 index 0000000..d88260b --- /dev/null +++ b/outft.txt @@ -0,0 +1 @@ +! ! diff --git a/srcs/ft_convert.c b/srcs/ft_convert.c index 0e49955..f2090fa 100644 --- a/srcs/ft_convert.c +++ b/srcs/ft_convert.c @@ -1,14 +1,3 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_convert.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: hulamy +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/02/27 12:03:28 by hulamy #+# #+# */ -/* Updated: 2020/02/27 17:34:06 by hulamy ### ########.fr */ -/* */ -/* ************************************************************************** */ #include "ft_printf.h" diff --git a/srcs/ft_flag_transform.c b/srcs/ft_flag_transform.c index df604ef..c87541b 100644 --- a/srcs/ft_flag_transform.c +++ b/srcs/ft_flag_transform.c @@ -1,14 +1,3 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_flag_transform.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: hulamy +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/02/27 11:55:43 by hulamy #+# #+# */ -/* Updated: 2020/02/27 18:17:34 by hulamy ### ########.fr */ -/* */ -/* ************************************************************************** */ #include "ft_printf.h" @@ -112,7 +101,7 @@ char *width_flags(char *print, char *tmp, char *s, int width) j = 0; if (ft_strchr(s, '-')) { - while (print[j]) + while (print[j] != '\0') tmp[i++] = print[j++]; while (i < width) tmp[i++] = ' '; @@ -122,7 +111,7 @@ char *width_flags(char *print, char *tmp, char *s, int width) c = (ft_strchr(s, '0')) ? '0' : ' '; while (i < (width - ft_strlen(print))) tmp[i++] = c; - while (print[j]) + while (print[j] != '\0') tmp[i++] = print[j++]; } free(print); @@ -132,6 +121,7 @@ char *width_flags(char *print, char *tmp, char *s, int width) /* ** -if there is a minimal width field, calculate it and add it to print ** according to the flags '-' and '0' if present +** -if print[0] value 0 */ char *ft_width(char *s, char *print) @@ -142,8 +132,12 @@ char *ft_width(char *s, char *print) tmp = s; while (*tmp != '\0' && ft_strchr("%#- +'0.", *tmp)) tmp++; + if (*tmp == '\0') + return (print); width = ft_atoi(tmp); tmp[0] = '\0'; + if (print[0] == '\0') + width--; if (width > ft_strlen(print)) { if (!(tmp = (char *)malloc(sizeof(char) * (width + 1))))