Remake of the printf C function.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
TaKouMyS 4596545529 norming 1 month ago
libft norming 1 month ago
src Norme + fix compilation problems 1 month ago
Makefile Update to include in libtf 4 months ago
README.md Update README.md 7 months ago
ft_printf.en.pdf added subject 7 months ago
maintest.c Create maintest.c 4 months ago

README.md

ft_printf

What is ft_printf?

This project is about recoding the famous printf C function to learn variadic functions and improve algorithmic methodology.

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

ft_printf can print different contents depending on conversions and flags. You can print using the following syntax:

%[flag][min-width].[precision][length modifier][conversion specifier]

min-width depending on cases, will add empty spaces. Precision, depending on cases, will add ‘0’.

See below what are flags, length modifier and conversions.

Features

Conversions:

c    char
s    char *
p    void * (to print pointer's adress)
f    floats
u    unsigned int
o    unsigned int (octal)
x/X: unsigned int (hexadecimal)
d/i: int

flags:

-       Left align.
+       Sign of number always O/P.
space   Positive values begin with a space.
0       Field is padded with 0's instead of space.
#       has different uses:
  %#o   0 prefix inserted.
  %#x   0x prefix added to non-zero values.
  %#X   0X prefix added to non-zero values.

length modifiers:

h       short
l       long
L       long double

Usage

You can try our project with the following commands:

First, clone the repository

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

then compile your file with the generated libftprintf.a by adding in the main

#include "src/ft_printf.h"

and use it like the real printf function.

Example

Screen Shot 2019-04-30 at 5 42 42 PM