Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

hanmpark/ft_printf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

52 Commits

Repository files navigation

ft_printf

A versatile and customizable formatted output function.


Description

The ft_printf project reimplements the standard C printf function.

The goal is to create a function capable of formatting and printing different types of data, supporting multiple conversion specifiers, flags, and modifiers. This project deepens the understanding of variadic functions, parsing, and formatted output.

Features

Function Prototype

int ft_printf(const char *, ...);

Supported Conversion Specifiers

  • %c - Character
  • %s - String
  • %p - Pointer address
  • %d / %i - Signed integers
  • %u - Unsigned integer
  • %x / %X - Hexadecimal (lowercase/uppercase)
  • %% - Percent sign

Supported Flags

  • - (left align)
  • 0 (zero padding)
  • . (precision)
  • # (alternate form for hex)
  • + (force sign)
  • space (prepend a space for positive numbers)

Installation

Clone the repository and compile the library:

git clone https://github.com/hanmpark/ft_printf.git
cd ft_printf
make

This will create libftprintf.a which you can link into your projects.


Usage

Example usage:

#include "ft_printf.h"

int main(void)
{
int count;

count = ft_printf("Hello %s! Number: %d, Hex: %x\n", "world", 42, 42);
ft_printf("Printed %d characters.\n", count);
return (0);
}

Compile with:

gcc main.c -L. -lftprintf -I. -o my_program

Authors

About

A versatile and customizable formatted output function

Topics

Resources

Readme

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors