From d650ffebcbcef97005d1565637ee83e836da510b Mon Sep 17 00:00:00 2001 From: yctct Date: Thu, 29 Jan 2026 19:11:33 +0100 Subject: Update license file, rm .txt --- README | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 README (limited to 'README') diff --git a/README b/README new file mode 100644 index 0000000..2e4ba9c --- /dev/null +++ b/README @@ -0,0 +1,88 @@ +ft_printf library +---------------- + +Description +---------- + +This is a custom implementation of printf() glibc. + +I wrote this implementation to carry on learning C and understand what printf +does, to an extend. + +This implementation is concerned with the following specifiers only: c, s, +i, d, u, x, X, p. + +Instructions +----------- + +To clone the repository of this library run: + + $ git clone https://git.yctct.com/ft_printf + $ cd ft_printf + +To compile the library run: + + $ make + +To recompile the library run: + + $ make re + +To delete all object files run: + + $ make clean + +To delete all object files and libft.a run: + + $ make fclean + +Then to use the library, libftprintf.a, with a programme, say main.c, run: + + $ cc main.c libftprintf.a + +and prepend each of the C files with: + + #include "path/to/ft_printf.h" + +Implementation choice +--------------------- + +ft_printf.c parses the string for the specifier. When it finds a specifier, a +helper function check the character following the specifier against conversion +specifier, when the condition is true (i.e. the char following the specifier is +a conversion specifier, then the argument pointer is passed to a function that +will convert the argument according to the conversion specifier. + +Possible improvements: + +- I could probably merge both functions converting decimal to hexadecimal into + a single function. +- At the end of my implement, I added a function, ft_checkpadd.c to check + whether the address a pointer is pointing to is zero. I could try to +integrate that function elsewhere. +- deal with edge case when % is the last char of a string + + +Some edge cases this implementation takes into account: + +- specifier followed by a non-conversation specifier character e.g. %t +- print(0); +- print (""); + +Relevant projects +----------------- + +- [add URL to printf test] + +Resources +--------- + +- Oceano's tutorials on variadic functions and "mini printf" +- man stdarg for variadic functions. +- man limits.h for INT_MAX, etc. +- man 3 printf + +License +------- + +GNU AGPLv3 -- cgit v1.2.3