diff options
| author | yctct <yctct> | 2026-01-28 12:43:28 +0100 |
|---|---|---|
| committer | yctct <yctct> | 2026-01-28 12:43:28 +0100 |
| commit | 925989f7e7af67d965e2b501a51068acfe449ab0 (patch) | |
| tree | 7a83e51d2872f9c97abf3166f883ff8dfcf7e2e0 /README.txt | |
Add all files, first commit
Diffstat (limited to 'README.txt')
| -rw-r--r-- | README.txt | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..ce18a02 --- /dev/null +++ b/README.txt @@ -0,0 +1,75 @@ +ft_printf library +---------------- + +Description +---------- + +This is a custom implementation of printf. + +I wrote this implementation to carry on learning C and understand what printf does, to an extend. + +This is 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 url directory_name + $ cd directory_name + +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, ft_printf.a, with a programme, say main.c, run: + + $ cc main.c libftprintf.a + +and append 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 +----------------- + +- tests for printf + +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 |
