Custom printf of 42 C School
/* unlike original printf
, this project doesn't support buffer manegement */
Variadic arguments
in<stdarg.h>
- Handling a number of arguments
- Standard output's
buffer I/O
- Condition checks using
flags
(orbitwise calculation
)
Buffer is a block of memory which belongs to a kernal stream and is used to hold stream data temporarily. Stdout is line buffered by default(ISO). Characters written to a line buffered stream are transmitted to the file in blocks when a newline character is encountered.
printf : %[Flag][Width][.Precision][Length]Specifier
ft_printf : %[Flag][Width][.Precision]Specifier
notes!
- Precision
.
means.0
. - A precision of 0 means that no character is written for the value 0.
- For integer, numbers
0 flag
is ignored if the precision is explicitly specified, also ignored when- flag
is present.
spec/flag | %c | %s | %p | %d | %i | %u | %x | %X | %% |
---|---|---|---|---|---|---|---|---|---|
width | o | o | o | o | o | o | o | o | x |
precision | x | o | o | o | o | x | o | o | x |
- | o | o | o | o | o | o | o | o | x |
0 | x | x | o | o | o | x | o | o | x |
# | x | x | x | x | x | x | o | o | x |
SPACE | x | x | o | o | x | x | x | x | x |
+ | x | x | o | o | x | x | x | x | x |
/ check_flag
- check_width
ft_printf - ft_vsprintf - check_precision
\ check_conversion - conversion %, c, s
\ conversion p, int, x - print_numbers
$(NAME) : $(OBJS)
$(MAKE) -C $(LIBFT_DIR) all //go into the libft dir and run make all
@cp $(LIBFT_DIR) $(LIBFT_LIB) $@ //cp the archived file as the name of the target
$(AR) $@ $^ //append printf's objs
- paulo-santana - examine over a thousand cases.
- francinette - Integrated testing framework for 42