Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ft_printf

A complete custom implementation of the C standard printf function for 42 School. Supports all mandatory format specifiers (c s p d i u x X %) and uses a modular helper system. No bonus formatting included.

🔥 ft_printf — 42 Project


📘 Overview

ft_printf is a custom re-implementation of the standard C function printf.

It prints formatted output to stdout using:

  • write()
  • variadic arguments (va_list, va_start, va_arg, va_end)
  • internal helper functions

It is a mandatory 42 core project and is widely reused in future projects.


✔️ Supported Format Specifiers

Format Meaning
%c Character
%s String
%p Pointer address
%d Integer (signed)
%i Integer (signed)
%u Unsigned integer
%x Hexadecimal (lowercase)
%X Hexadecimal (uppercase)
%% Literal % symbol

📁 Project Structure

📦 ft_printf/ ├── ft_printf.c ├── ft_helpers.c ├── ft_helpers1.c ├── ft_printf.h ├── Makefile └── README.md

  • ft_printf.c — main dispatcher and parsing logic
  • ft_helpers.c & ft_helpers1.c — conversion & printing utilities
  • ft_printf.h — prototypes, includes, typedefs

⚙️ Compilation

Build the static library:

make

This will create:

libftprintf.a

Remove object files:

make clean

Remove object files + library:

make fclean

Rebuild from scratch:

make re

🧪 Example Usage

#include "ft_printf.h"

int main(void)
{
    ft_printf("Hello %s! Number: %d Hex: %x\n", "World", 42, 42);
    return 0;
}

Compile with your library:

cc main.c libftprintf.a

💡 Key Concepts

  • Variadic arguments (stdarg.h)

  • Manual formatting without libc formatting

  • Direct output using write()

  • Type dispatching and conversion

  • No dynamic memory required (except strings if implemented)

🚫 Not Included (as required)

❌ Width ❌ Precision ❌ Flags (-, 0, #, +, space) ❌ Bonus formatting

🧑‍💻 Author

Emanuel Tchipoque

🔗 LinkedIn: Emanuel Tchipoque

About

A complete custom implementation of the C standard printf function for 42 School. Supports all mandatory format specifiers (c s p d i u x X %) and uses a modular helper system. No bonus formatting included.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages