Skip to content

A reimplementation of the C printf function, built in C at 42, handling format specifiers, flags, width, precision, and variable arguments according to 42 coding standards.

Notifications You must be signed in to change notification settings

M677871/ft_printf

Repository files navigation

ft_printf

A minimal reimplementation of the C printf function for the 42 cursus.

Description

ft_printf is a student reimplementation of the standard printf function. It provides formatted output for a subset of conversion specifiers and is intended for the 42 school project requirements.

Features

  • Supported conversion specifiers (typical for this project): %c, %s, %p, %d, %i, %u, %x, %X, %%.
  • Handles signed/unsigned integers and hexadecimal output.
  • Small, self-contained implementation using the functions in this repository.

Repository files

  • ft_printf.c — entry point / format parser
  • ft_printf.h — function prototypes and includes
  • ft_putchar.c — write a single character
  • ft_putstr.c — write a string
  • ft_putnbr.c — write signed integers
  • ft_putunbr.c — write unsigned integers
  • ft_putnbr_base.c — write numbers in arbitrary base (hex handling)
  • ft_strlen.c — helper: string length
  • Makefile — build rules (creates libftprintf.a)

If your local tree contains additional helper files, list them here.

Build

This repository includes a Makefile that builds a static library named libftprintf.a.

To build:

make

Common make targets:

  • all (default) — builds libftprintf.a
  • bonus — builds with bonus object files (if BONUS is set in the Makefile)
  • clean — remove object files
  • fclean — remove object files and libftprintf.a
  • refclean then all

Note: The provided Makefile in this repo sets NAME = libftprintf.a.

Usage

Link the static library into your test program. Example:

# build the library
make

# compile a test program (assumes main.c includes ft_printf.h)
gcc -Wall -Wextra -Werror -L. -lftprintf main.c -o test

# run
./test

Example main.c:

#include "ft_printf.h"

int main(void)
{
    ft_printf("Hello %s! number: %d hex: %x\n", "world", 42, 42);
    return 0;
}

Author

  • miissa

About

A reimplementation of the C printf function, built in C at 42, handling format specifiers, flags, width, precision, and variable arguments according to 42 coding standards.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published