Skip to content

Iqwertzuiop/ft_printf

Repository files navigation

ft_printf - because ft_putnbr() and ft_putstr() aren’t enough 😁


In this project we mimic the original printf() function.

its job is to output formatted data to the stdout more information on stdout (Standard Output Stream)
👇👇👇 Here is an example usage of the function 👇👇👇

Ever imagined how printf works❓lets dive in... 🏊‍♂️

  • In this project we learn how to use Variadic Arguments or an amazing feature called "Ellipsis". this feature allows us to pass an unfixed amount of arguments to the function.

The prototype of ft_printf() is :

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

in the prototype we can see the usage of the so-called Ellipsis by using the 3 dots (...) (more information on Variadic Arguments)

  • The function can optionaly contain embedded "format specifiers" that are replaced by the values specified in subsequent additional arguments and formatted as requested.

A format specifier follows this prototype :

%[flags][width][.precision][length]specifier

In this project we only handle the following conversions: cspdiuxX% (more information on format specifiers)

Usage

Compile the code using -> make all

of course we would need a main function, either write one inside the ft_printf.c file or by creating a main file main.c

int main(void)
{
      // Call the function
      ft_printf("Testing!!");
      return (0);
}

Compile the library that was created earlier with the main.c :

gcc main.c libftprintf.a

Run the program :

./a.out

Output should be :

Testing!!

Have you seen what printf can do ❓😯

About

a clone to the original printf() in libc

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published