Skip to content

dbislimi/ft_printf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ft_printf

Reimplementation of printf in C using variadic arguments (va_list, va_start, va_arg).

Build

make
cc main.c -L. -lftprintf -o program
#include "ft_printf.h"

ft_printf("Hello, %s! You are %d years old.\n", name, age);
ft_printf("Pointer: %p\n", ptr);
ft_printf("Hex: %x / %X\n", 255, 255);  // ff / FF

How it works

The format string is scanned character by character. When % is found, the next character determines which conversion to apply. Each conversion writes directly to stdout via write(). Returns the total number of characters printed, same as the real printf.

Supported conversions

Specifier Output
%c Single character
%s String ((null) if NULL)
%p Pointer address (0x + lowercase hex)
%d / %i Signed decimal integer
%u Unsigned decimal integer
%x / %X Hex lowercase / uppercase
%% Literal %

Files

├── ft_printf.h           - prototypes
├── ft_printf.c           - main function + format parser
├── ft_printf_utils1.c    - %c, %s, %p
└── ft_printf_utils2.c    - %d, %i, %u, %x, %X

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors