Ft_printf is a variadic function that recreates much of printf's functionalities.
Language & Functions Used | Installation & Usage | Format Specification Fields
The ft_printf function is written in C, using only the following functions from the standard C libraries:
- write
- stdarg
$ git clone https://github.com/serena-zhu/ft_printf.git$ makeThe Makefile will compile a static library called libftprintf.a, which can be compiled with your program source files as follows:
$ gcc -Wall -Wextra -Werror -o program_name source_file -L ./ft_printf -lftprintf- #
- 0
- -
- +
- space
- '
- # [given as any hardcoded number e.g. ft_printf("%4d\n", number);]
- * [given as a variable e.g. ft_printf("%*d\n", 4, number); Note: if a negative number is provided, the absolute value will be used and a '-' flag will be added]
- .# [given as any hardcoded number e.g. ft_printf("%.2f\n", number);]
- .* [given as a variable e.g. ft_printf("%.*f\n", 2, number);]
- hh
- h
- l
- ll
- j
- z
- L
- s, S
- p
- d, D, i
- o, O
- u, U
- x, X
- c, C
- e, E
- f, F
- g, G
- n
This function includes a color management functionality that is different from printf.
To use: specify colors in between {} and end color with {eoc}. If the closing bracket } is missing, the opening bracket { and the texts that follow will be printed to standard output.
Example:
$ cat main.c
#include "ft_printf.h"
int main(void)
{
ft_printf("This will be{red} red text {eoc}and now the text color is back to default.\n");
return (0);
}
$ gcc -Wall -Wextra -Werror main.c -L ./ft_printf -lftprintf
$ ./a.outSupported colors are:
- black | red | green | yellow | blue | magenta | cyan | white | gray
- light red | light green | light yellow | light blue | light magenta | light cyan