Because I'm bored of ft_putstr 😎 Actually, no. I was just not allowed to use printf in my school projects, so I recoded my own. This project covers implementation of a C laguage feature – variadic functions. It also includes practice detailed management of the printing options via dispatch tables (which I unfortunately did not implement in this project when I was a beginner - I know, shame on me 😳).
Argument prototype: %[flags][width/margin][.precision][hh|h|l|ll|j|z]type, where:
- flags:
+ || - |||| # || 0; - width/margin:
- min amount of displayed digits, does not cut digits if less, fill with spaces on the left side;
- if
*added it's necessary to pass one more parameter with a number of spaces before the actual parameter;
- .precision:
- for
diouxXmin amount of digits, fill with 0 is necessary; - for
eEfamount of digits after dot; - for
gGamount of all digits, if bigger displays number; - for
sSmax amount of characters; - if
*added is necessary to pass one more parameter with a number of spaces before the actual parameter;
- for
- [hh|h|l|ll|j|z|q]: default values' modification:
hh: foridouxX- char;h: foridouxX- short int;l: foridouxX- long int, for feE - double;ll: foridouxX- long long int;j: foridouxX- intmax_t;z: foridouxX- size_t;q: forCS- prints Unicode
Copy and paste to your terminal following text:
git clone https://github.com/psprawka/Ft_printf.git 42SV_ft_printf
cd 42SV_ft_printf
make
This will create a static library - libftprintf.a - which you just need to include to the project that you need ft_printf in. 🔧
