The goal of this project is pretty straightforward.
You will recode printf().
You will mainly learn about using a variable number of arguments. How cool is that??
It is actually pretty cool :)
subject v.9.2
Project Structure 📂
├── README.md
├── LICENSE
├── Dockerfile
├── project
│ ├── ft_printf_assembly_line.c
│ ├── ft_printf.c
│ ├── ft_printf_format.c
│ ├── ft_printf.h
│ ├── Makefile
│ └── libft
└── _subject
└── en.subject.pdf
This project involves the use of variadic functions, which allow for a flexible number of arguments to be passed to a function. Specifically, it requires the use of the standard macros va_start, va_arg, va_copy, and va_end to correctly access and process these arguments. These macros are essential for managing the stack and retrieving each argument in sequence. Proper implementation ensures that the function can handle an arbitrary number of arguments, thus mimicking the behavior of the original printf() function.
The project demands a comprehensive understanding of format specifiers to replicate the behavior of the standard printf(). The function must handle the following format specifiers:
- c – Character
- s – String
- p – Pointer
- d/i – Signed integer
- u – Unsigned integer
- x – Hexadecimal (lowercase)
- X – Hexadecimal (uppercase)
- % – Literal percent sign
Each specifier requires careful handling of its corresponding data type and proper formatting of the output, ensuring consistency with the standard printf() function in terms of both behavior and edge-case management.
git clone https://github.com/kichkiro/ft_printf.git
cd ft_printf/
docker build -t ft_printf:42 .
docker run -d --name ft_printf ft_printf:42
docker cp ft_printf:/usr/src/app/ft_printf/libftprintf.a .
The static library libftprintf.a is now in the current dir, so it can be included in C code.
The function prototype is int ft_printf(const char *, ...);
See LICENSE