my_printf is a C programming project that aims to replicate the functionality of the standard printf function. This project is part of the Epitech curriculum and serves as an introduction to low-level programming concepts, variadic functions, and formatted output handling.
The goal of my_printf is to understand and implement the logic behind the widely-used printf function available in the C standard library. This involves handling formatted strings, processing various data types, and creating a modular and efficient implementation.
Through this project, developers will gain deeper insights into:
- Variadic function handling (
stdarg.h) - Format specifiers (e.g.,
%d,%s,%c, etc.) - String manipulation
- Modular and reusable code design in C
-
Custom Format Specifiers
Supports a subset ofprintf's format specifiers, including:%d/%i: Integer%s/%S: String%c: Character%u: Unsigned integer%x/%X: Hexadecimal (lowercase/uppercase)%o: Octal%%: Percent sign%p: Pointer%n: Get number of char%f/%F: Float (lowercase/uppercase)%e/%E: Scientific notation (mantissa/exponent), lowercase/uppercase%b: Binary%a: Hexadecimal floating point
-
Error Handling
Handles edge cases and invalid input gracefully. -
Optimized Performance
Designed with efficiency in mind for handling real-time formatted output.
-
C Programming Language: 95%
The core language for the project, focusing on low-level capabilities and performance. -
Makefile: 5%
Automates the build process for compiling the project efficiently.
my_printf/
├── my_printf.c # Core implementation of the printf function
├── lib/my/ # Additionals functions
├── src/ # Source code files
│ ├── flags/ # (-, +, , #, 0)
│ ├── specifiers/ # (%d, %i, %u, %c, etc.)
| └── utils # Utils files
├── include/ # Header files
│ └── my.h # Function prototypes and macros
├── tests/ # Criterion tests
├── Makefile # Build automation
└── README.md # Project documentation
-
Clone the repository:
git clone https://github.com/Akinator31/my_printf.git cd my_printf -
Build the project using the provided
Makefile:make
-
Include
my_printfin your project:#include "my_printf.h" int main() { my_printf("Hello, %s! The number is %d.\n", "world", 42); return 0; }
-
Run your program:
./your_program
To ensure the reliability of my_printf, test cases have been provided. Run the tests with the following command:
make testsThis project is designed to:
- Deepen understanding of variadic functions and argument handling.
- Develop an appreciation for the complexity of standard library functions.
- Practice memory management and error handling in C.
- Improve debugging and testing skills.
#-42