This is a custom implementation of the `printf` function in C that supports various format specifiers, The function also writes output directly to the standard output using `write`, and returns the number of characters printed (similar to the standard printf).
File Name | Description |
---|---|
main.h |
Header file that contains function prototypes and necessary includes. |
charactrs.c |
Functions that handle printing characters, strings, and non-printable characters. |
number.c |
Functions that handle printing numbers in decimal format. |
number_base.c |
Functions that print numbers in different bases (binary, octal, uppercase hexadecimal, and lowercase hexadecimal). |
pointers.c |
Functions that handle printing pointer addresses, Rot13 encoding, and reversed strings. |
printf.c |
The main _printf function that mimics the behavior of printf (under 40 lines). |
printf_merv.c |
A more extended version of _printf (over 40 lines, with a slightly different function prototype). |
test/main.c |
The main function used to test the implemented printf function. |
- Case 1: Handling %c: Character
- Case 2: Handling %s: String of characters
- Case 3: Handling %d or %i: Signed decimal integer
- Case 4: Handling %b: Unsigned binary
- Case 5: Handling %u: Unsigned decimal integer
- Case 6: Handling %o: Unsigned octal
- Case 7: Handling %x: Unsigned hexadecimal integer (lowercase)
- Case 8: Handling %X: Unsigned hexadecimal integer (uppercase)
- Case 9: Handling %S: Custom conversion specifier
- Case 10: Handling %p: Pointer address
- Case 11: Handling %r: Custom conversion specifier, reversed string.
- Case 12: Handling %R: Custom conversion specifier, Rot13'ed string.
Include the header file that declares printf_ and the relevant specifier functions (if implemented in separate files). Link the object files that contain the implementation of your printf function. Call printf_ with the desired format string and arguments. compile it this way : __gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c