Skip to content

Replicates standard printf function in C. This project deepens understanding of variadic functions, data formatting, and low-level I/O management.

Notifications You must be signed in to change notification settings

pin3dev/42_ft_Printf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 

Repository files navigation

ft_Printf

🗣️ Introduction

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.

🧬 Project Structure

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.

🗃️ Documentation

For detailed documentation, including usage examples, please visit the link below:

🫥 Cloning the Repository

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.

🕹️ Compilation and Usage

Makefile

A Makefile is provided to automate the compilation process. It includes the following rules:

  • all: Compiles the library and generates the libftprintf.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 in test/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.

Basic Usage

To use the ft_printf library in your C code, follow the steps below:

  1. Include the header in your code:

    #include "42_ft_Printf/printf/inc/ft_printf.h"
  2. 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
  3. You can now use the ft_printf function in your program as follows:

    ft_printf("Hello, %s! The number is %d.\n", "world", 42);

⚠️ Norms and Guidelines Disclaimer

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.

📖 Theoretical Background

All the theoretical material used to develop this project is organized and can be accessed directly via the link below:

About

Replicates standard printf function in C. This project deepens understanding of variadic functions, data formatting, and low-level I/O management.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published