https://github.com/ychaaibi/ft_printf
Custom Printf Function in C π
https://github.com/ychaaibi/ft_printf
1337school c printf printf-42 variadic-functions
Last synced: 6 months ago
JSON representation
Custom Printf Function in C π
- Host: GitHub
- URL: https://github.com/ychaaibi/ft_printf
- Owner: ychaaibi
- Created: 2024-01-11T18:36:50.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-12T17:55:25.000Z (almost 2 years ago)
- Last Synced: 2025-06-09T10:04:03.582Z (6 months ago)
- Topics: 1337school, c, printf, printf-42, variadic-functions
- Homepage:
- Size: 1.44 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Custom Printf Function in C π
[ Project Completion Date : 2021 - 11 - 24 ]
## Project Overview π
The project challenges me to replicate the functionality of the C standard libraryβs `printf` function to `ft_printf`. This function is complex and widely used for formatted output, making it a keystone of C programming. My implementation handles various conversion specifiers, flags, width, precision, and length modifiers, following the genuine behavior of `printf`.
### Development Approach π οΈ
- **Variadic Functions:** I delve into the usage of `stdarg.h` to manage an undefined number of function arguments, replicating the flexibility of the native `printf`.
- **String Processing:** String manipulation lies at the heart of this project as I work through parsing format strings, generating output, and managing buffers.
- **Modularity:** The code is structured into modular components, each handling different aspects of `printf` functionality, facilitating readability and maintainability.
- **Unit Testing:** Rigorous test cases are developed to cover a wide range of input scenarios, ensuring the reliability and robustness of `ft_printf`.
### Highlights β¨
- **Supported Features:** Custom implementation supports various features including conversion specifiers (`%c`, `%s`, `%d`, `%i`, `%u`, `%x`, `%X`, `%o`, `%p`, `%S`, and `%%`).
- **Format String Compliance:** My code closely emulates the parsing of format strings and handles compound formatting options consistently with the standard `printf`.
### Additional Features π
- **Manage any combination of the following flags: β-0.β and the field minimum width under all conversions.**
- **Manage all the following flags: β# +β (Yes, one of them is a space).** ππ οΈ
## Project Conclusion π
Through this project, I deepened my understanding of the C language internals and developed a solid intuition for how high-level functions can be broken down into discrete, logical operations. Emphasizing hands-on practice, comprehensive testing, and attention to detail, I effectively created a close approximation of one of the most intricate standard library functions.