This repository contains the implementation of a custom printf function, part of a coding project for the 42 School program.
The goal of the ft_printf project is to recreate the functionality of the standard C printf function. This involves handling strings, type conversions, and output formatting in a versatile manner, allowing for a deeper understanding of the internal workings of this common function.
This implementation supports various format specifiers and data types, making it useful for future projects that cannot rely on the standard C library.
The structure of the project focuses on creating a main function, ft_printf, which can handle different data types and formatting, such as strings, integers, characters, and hexadecimals. The project is composed of several auxiliary functions that manipulate and format these data types as needed.
For detailed documentation, including usage examples, please visit the link below:
To clone this repository and compile the project, run the following commands:
git clone https://github.com/pin3dev/42_ft_Printf.git
cd 42_ft_Printf/printf
This will download the project from GitHub into your local machine in current directory. Once inside the printf
directory, you must run make to compile the library.
A Makefile
is provided to automate the compilation process. It includes the following rules:
all
: Compiles the library and generates thelibftprintf.a
file.clean
: Removes object files.fclean
: Removes object files and the library.re
: Recompiles the entire project.test
: Compiles the project and runs the test stored intest/main.c
To compile the library, simply run:
make
This will generate the libftprintf.a
library, which can be linked in other projects to use the ft_printf function.
To use the ft_printf library in your C code, follow the steps below:
-
Include the header in your code:
#include "42_ft_Printf/printf/inc/ft_printf.h"
-
Compile your code with the library:
cc -Wall -Wextra -Werror -o your_exec your_code.c -L 42_ft_Printf/printf/ -lftprintf -L 42_Libft/libft/ -lft
-
You can now use the
ft_printf
function in your program as follows:ft_printf("Hello, %s! The number is %d.\n", "world", 42);
This project strictly follows the 42 School Norm coding guidelines, which significantly influenced certain decisions in its implementation. These rules may sometimes lead to seemingly inefficient or unusual solutions, but they were necessary to meet the strict requirements of the school.
All the theoretical material used to develop this project is organized and can be accessed directly via the link below: