diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-10-29 01:57:41 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-10-29 02:02:09 +0100 |
| commit | 87bce91050b56915dcf5964f6f66d5f47299e7f3 (patch) | |
| tree | 8c8fef15ffb962cfa860181ffad3fdd52c71b4f0 /main.c | |
| parent | f6ee1462e26d723cf5d53157eadaff2804d18c3a (diff) | |
| download | ft_printf-87bce91050b56915dcf5964f6f66d5f47299e7f3.tar.gz ft_printf-87bce91050b56915dcf5964f6f66d5f47299e7f3.tar.bz2 ft_printf-87bce91050b56915dcf5964f6f66d5f47299e7f3.zip | |
Reworking, binary flags, extract advance
- Binary flags attribute instead of multiple bool
- Extract doesnst strdup fmt each time, just advance the current pointer
- In parsing push front then reverse
- Moved some functions to libf
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 63 |
1 files changed, 46 insertions, 17 deletions
@@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/10/28 04:25:09 by cacharle #+# #+# */ +/* Updated: 2019/10/29 00:04:49 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include <stdio.h> #include "libft.h" #include "header.h" @@ -6,29 +18,46 @@ int main() { int test; - printf("bonjour"); - ft_printf("char: %c\n", 'r'); - ft_printf("string: %s\n", "bonjour"); - ft_printf("pointer: %p\n", &test); - ft_printf("int: %d or %i\n", 45, 54); - ft_printf("uint: %u\n", 1 << 31); - ft_printf("hex lower: %x\n", 0xabcf012); - ft_printf("hex upper: %X\n", 0xabcf012); - ft_printf("percent: %%\n"); + ft_printf("char: %c\n", 'r'); + ft_printf("string: %s\n", "bonjour"); + ft_printf("pointer: %p\n", &test); + ft_printf("int: %d or %i\n", 45, 54); + ft_printf("uint: %u\n", 1 << 31); + ft_printf("hex lower: %x\n", 0xabcf012); + ft_printf("hex upper: %X\n", 0xabcf012); + ft_printf("percent: %%\n"); + ft_printf("multiple stuff: %d %u %d %x %d\n", 1, -2, 3, 0xa, 5); - ft_printf("precision |%.9d|\n", 43); - ft_printf("string precision |%.9s|\n", "jesuisbonjourbonjour"); - ft_printf("min width |%9d|\n", 43); - ft_printf("zero padding |%09d|\n", 43); - ft_printf("left adjusted |%-9d|\n", 43); - ft_printf("string padding |%9s|\n", "bon"); + ft_printf("precision |%.9d|\n", 43); + printf("precision |%.9d|\n", 43); + ft_printf("string precision |%.9s|\n", "jesuisbonjourbonjour"); + printf("string precision |%.9s|\n", "jesuisbonjourbonjour"); + ft_printf("min width |%9d|\n", 43); + printf("min width |%9d|\n", 43); + ft_printf("zero padding |%09d|\n", 43); + printf("zero padding |%09d|\n", 43); + ft_printf("left adjusted |%-9d|\n", 43); + printf("left adjusted |%-9d|\n", 43); + ft_printf("string padding |%9s|\n", "bon"); + printf("string padding |%9s|\n", "bon"); ft_printf("width wildcard |%*d|\n", 5, 43); + printf("width wildcard |%*d|\n", 5, 43); ft_printf("precision wildcard |%.*d|\n", 5, 43); + printf("precision wildcard |%.*d|\n", 5, 43); ft_printf("precision/width wildcard |%*.*d|\n", 5, 3, 43); + printf("precision/width wildcard |%*.*d|\n", 5, 3, 43); ft_printf("left adjusted |%*d|\n", -5, 43); + printf("left adjusted |%*d|\n", -5, 43); + + ft_printf("overwrite |%*3d|\n", 5, 43); + printf("overwrite |%*3d|\n", 5, 43); + ft_printf("overwrite neg |%*-1d|\n", 0, 43); + printf("overwrite neg |%*-1d|\n", 0, 43); - /* ft_printf("overwrite |%*3d|\n", 5, 43); */ - /* ft_printf("overwrite |%*-1d|\n", 0, 43); */ + /* ft_printf("pointer field width |%15p|\n", &test); */ + /* printf("pointer field width |%15p|\n", &test); */ + /* ft_printf("pointer precision |%.15p|\n", &test); */ + /* printf("pointer precision |%.15p|\n", &test); */ return 0; } |
