This project involves creating a custom printf function, named ft_printf
, that mimics the behavior of the original printf
function from the C standard library. The goal is to implement a subset of format specifiers and conversions to handle character, string, pointer, decimal, integer, unsigned decimal, and hexadecimal printing.
-
Makefile: Contains rules for compilation (
all
), cleaning (clean
), force cleaning (fclean
), and recompilation (re
). -
libftprintf.h: Header file containing function prototypes and necessary declarations.
-
*.c: Source files containing the implementation of the
ft_printf
function and related helper functions.
-
Clone the repository:
git clone https://github.com/your-username/ft_printf.git
-
Navigate to the project folder:
cd ft_printf
-
Compile the library:
make
This will generate the
libftprintf.a
library. -
Use the library in your C projects:
-
Copy the
libftprintf.a
file to your project folder. -
Include the
libftprintf.h
header file in your C files. -
Compile your project with the library:
gcc -Wall -Wextra -Werror -o your_program your_file.c libftprintf.a
-
-
Clean up:
make clean
This removes object files.
-
If you want to remove the library and object files:
make fclean
The ft_printf
function can be used to format and print data to the standard output. It supports the following conversions:
%c
: Prints a single character.%s
: Prints a string.%p
: Prints a void pointer in hexadecimal format.%d
/%i
: Prints a decimal (base 10) number.%u
: Prints an unsigned decimal (base 10) number.%x
: Prints a number in hexadecimal (base 16) lowercase format.%X
: Prints a number in hexadecimal (base 16) uppercase format.%%
: Prints a percent sign.
- The
ft_printf
function does not implement the buffer management of the originalprintf
.