ft_printf is a project to recreate the functionality of the C standard library's printf()
function, focusing on variadic functions and extensible programming.
The project is a part of Hive Helsinki coding school (School 42) studies.
int ft_printf(const char *, ...);
-
Supported Conversions:
%c
: Single character.%s
: String.%p
: Pointer address in hexadecimal.%d
: Decimal number.%i
: Integer in base 10.%u
: Unsigned decimal number.%x
: Lowercase hexadecimal.%X
: Uppercase hexadecimal.%%
: Percent sign.
-
Adheres to Hive Norm standards, ensuring robust memory management and error handling.
- Implemented as a static library:
libftprintf.a
. - Makefile with rules:
all
,clean
,fclean
,re
. - Tested against the standard
printf()
function.
cc tests/main.c ft_printf.c ft_printf_utils.c
./a.out
- I mastered working with variadic arguments using macros like
va_start
,va_arg
, andva_end
. - This skill is essential for understanding how low-level functions process variable numbers of parameters, which is a common technique in embedded systems and system-level programming.
- I learned to design modular and reusable code. By creating a structured approach to handle various format specifiers (
%c
,%s
,%d
, etc.), I developed a library that was extensible and easy to debug.
- I gained experience in robust error handling to avoid undefined behavior, such as buffer overflows.
- The project required strict compliance with the 42 School Norm, which emphasized clean and maintainable code—a practice I follow in all my work.
- Low-Level C Programming: Deepened my understanding of the standard library, system calls like
write
, and how functions likeprintf
operate under the hood. - Attention to Detail: Learned to meet strict project requirements and match the output of a highly versatile function.
- If I revisited the project, I would optimize the buffer management to minimize the number of
write
system calls, making the function even more efficient for resource-constrained environments.