https://github.com/artidek/42_ft_printf
A custom implementation of the C standard library's printf function. This project recreates printf with support for formatting, variable arguments, and buffer management, demonstrating deep understanding of C programming, variadic functions, and memory handling.
https://github.com/artidek/42_ft_printf
42school buffer-management c error-handling variadic-functions
Last synced: about 24 hours ago
JSON representation
A custom implementation of the C standard library's printf function. This project recreates printf with support for formatting, variable arguments, and buffer management, demonstrating deep understanding of C programming, variadic functions, and memory handling.
- Host: GitHub
- URL: https://github.com/artidek/42_ft_printf
- Owner: artidek
- Created: 2025-06-19T10:25:20.000Z (6 days ago)
- Default Branch: main
- Last Pushed: 2025-06-20T18:01:52.000Z (4 days ago)
- Last Synced: 2025-06-20T19:31:33.764Z (4 days ago)
- Topics: 42school, buffer-management, c, error-handling, variadic-functions
- Language: C
- Homepage:
- Size: 1.46 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 42_ft_printf
Welcome! This repository contains my implementation of the C `printf` function as required by the 42 school curriculum. The goal of this project was to deeply understand formatted output in C, handle variadic functions, and manage memory and buffers efficiently. I focused on writing clean, modular, and standard-compliant code, closely following the project specifications.
---
## 🚩 Project Overview
I developed a custom version of `printf`, called `ft_printf`, which replicates the essential features and behavior of the standard function as outlined in the 42 subject PDF. This includes support for common format specifiers (`%d`, `%s`, `%c`, `%x`, `%p`, `%i`, `%u`, `%X`, `%%`), flags, width, and precision handling.
### Key Points
- **Comprehensive Format Support:** Handles all required specifiers, flags, width, and precision per the assignment.
- **Modular Source Structure:** Parsing, formatting, and output logic are separated for readability and maintainability.
- **Performance and Safety:** Variadic arguments and buffer management are implemented with care to avoid leaks and undefined behavior.
- **Custom Libft Integration:** Relies on my own C utility library (`libft`), as is standard for 42 projects.---
## 📁 Main Files and Structure (Partial)
- `ft_printf.c`, `ft_print_*.c` — Main implementation and helper modules
- `libftprintf.h` — Header with function prototypes and type definitions
- `libft/` — Personal C library required by the project
- `Makefile` — Build system for compiling and testing> This is a partial listing. For the complete codebase, see the [repository directory](https://github.com/artidek/42_ft_printf/tree/main).
---
## 🛠️ How to Use
1. **Clone the repository:**
```sh
git clone https://github.com/artidek/42_ft_printf.git
cd 42_ft_printf
```2. **Build the library:**
```sh
make
```3. **Include and use in your code:**
```c
#include "libftprintf.h"
int main(void) {
ft_printf("Hello, 42! Score: %d\n", 100);
return 0;
}
```
Link the generated library when compiling your project.---
## 🤝 Contributing
Feedback and suggestions are welcome. Please open an issue or submit a pull request if you have improvements or questions.
---
## ⚖️ License
This code is shared for educational and personal use as part of the 42 school curriculum.
---