├── Makefile ├── README.md ├── ft_flags.c ├── ft_flags_utils.c ├── ft_nbr_len.c ├── ft_print_char.c ├── ft_print_flag.c ├── ft_print_hex.c ├── ft_print_int.c ├── ft_print_ptr.c ├── ft_print_str.c ├── ft_print_unsigned.c ├── ft_printf.c ├── ft_printf.h ├── ft_printf_itoa.c ├── ft_printf_utoa.c ├── ft_printf_xtoa.c ├── libft ├── .gitignore ├── Makefile ├── ft_atoi.c ├── ft_bzero.c ├── ft_calloc.c ├── ft_isalnum.c ├── ft_isalpha.c ├── ft_isascii.c ├── ft_isdigit.c ├── ft_isprint.c ├── ft_itoa.c ├── ft_lstadd_back.c ├── ft_lstadd_front.c ├── ft_lstclear.c ├── ft_lstdelone.c ├── ft_lstiter.c ├── ft_lstlast.c ├── ft_lstmap.c ├── ft_lstnew.c ├── ft_lstsize.c ├── ft_memchr.c ├── ft_memcmp.c ├── ft_memcpy.c ├── ft_memmove.c ├── ft_memset.c ├── ft_putchar_fd.c ├── ft_putendl_fd.c ├── ft_putnbr_fd.c ├── ft_putstr_fd.c ├── ft_split.c ├── ft_strchr.c ├── ft_strdup.c ├── ft_striteri.c ├── ft_strjoin.c ├── ft_strlcat.c ├── ft_strlcpy.c ├── ft_strlen.c ├── ft_strmapi.c ├── ft_strncmp.c ├── ft_strnstr.c ├── ft_strrchr.c ├── ft_strtrim.c ├── ft_substr.c ├── ft_tolower.c ├── ft_toupper.c └── libft.h └── testing ├── Makefile ├── main.c └── test /Makefile: -------------------------------------------------------------------------------- 1 | NAME = libftprintf.a 2 | 3 | CC = gcc 4 | CFLAGS = -Wall -Wextra -Werror 5 | AR = ar 6 | ARFLAGS = rcs 7 | RM = rm -rf 8 | 9 | SRC = ft_printf ft_print_char ft_print_str ft_print_hex ft_print_int ft_print_ptr ft_print_unsigned ft_nbr_len ft_flags ft_flags_utils ft_print_flag ft_printf_itoa ft_printf_utoa ft_printf_xtoa 10 | SRCS = $(addsuffix .c, $(SRC)) 11 | 12 | OBJ_DIR = obj 13 | OBJS = $(SRCS:%.c=$(OBJ_DIR)/%.o) 14 | 15 | LIBFT_PATH = ./libft 16 | LIBFT = $(LIBFT_PATH)/libft.a 17 | 18 | $(OBJ_DIR)/%.o: %.c 19 | $(CC) $(CFLAGS) -c $< -o $@ 20 | 21 | all: $(NAME) 22 | 23 | bonus: all 24 | 25 | $(NAME): $(LIBFT) $(OBJ_DIR) $(OBJS) 26 | cp $(LIBFT) $(NAME) 27 | $(AR) $(ARFLAGS) $(NAME) $(OBJS) 28 | 29 | $(LIBFT): 30 | make -C $(LIBFT_PATH) all 31 | 32 | $(OBJ_DIR): 33 | mkdir -p $(OBJ_DIR) 34 | 35 | clean: 36 | make -C $(LIBFT_PATH) clean 37 | $(RM) $(OBJ_DIR) 38 | 39 | fclean: clean 40 | make -C $(LIBFT_PATH) fclean 41 | $(RM) $(NAME) 42 | 43 | re: fclean all 44 | 45 | .PHONY: all bonus clean fclean re libft -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ft_printf 2 | 3 |
4 |
5 |
%[flags][width][.precision]specifier
51 |
52 | The table below lists supported format specifiers:
53 |
54 | Flags |
58 | ||
---|---|---|
Flag | 61 |Description | 62 ||
- | 68 |Left justify the result within the field. By default it is right justified. | 69 ||
+ | 72 |Forces to precede the result with a plus or minus sign (+ or -) even for positive numbers. By default, only negative numbers are preceded with a sign. | 73 ||
(space) | 76 |If there is no sign, a space is attached to the beginning of the result. | 77 ||
# | 80 |Used with x or X specifiers the value is preceded with 0x or 0X respectively for values different than zero. | 81 ||
0 | 84 |Leading zeros are used to pad the numbers instead of space. | 85 ||
Width |
90 | ||
Value | 93 |Description | 94 ||
(number) | 100 |Minimum number of characters to be printed. If the value to be printed is shorter than this number, the result is padded with blank spaces. The value is not truncated even if the result is larger. | 101 ||
* | 104 |The width is not specified in the format string, but as an additional integer value argument preceding the argument that has to be formatted. | 105 ||
Precision |
110 | ||
Value | 113 |Description | 114 ||
.(number) | 120 |For integer specifiers (d, i, u, x, X) − precision specifies the minimum number of digits to be written. If the value to be written is shorter than this number, the result is padded with leading zeros. The value is not truncated even if the result is longer. A precision of 0 means that no character is written for the value 0. For s − this is the maximum number of characters to be printed. By default all characters are printed until the ending null character is encountered. For c type − it has no effect. When no precision is specified, the default is 1. If the period is specified without an explicit value for precision, 0 is assumed. | 121 ||
.(*) | 124 |The precision is not specified in the format string, but as an additional integer value argument preceding the argument that has to be formatted. | 125 ||
Specifiers |
130 | ||
Format Specifier | 133 |Description | 134 ||
% | 140 |% followed by another % character writes % to the screen. | 141 ||
c | 144 |writes a single character. | 145 ||
s | 148 |writes a character string. | 149 ||
p | 152 |writes an implementation-defined character sequence defining a pointer address. | 153 ||
d or i | 156 |writes a signed integer to decimal representation. | 157 ||
u | 160 |writes an unsigned integer to decimal representation. | 161 ||
x or X | 164 |writes an unsigned integer to hexadecimal representation. | 165 |