/ft_printf

Coding legendary printf() function from scratch. Everyone can use it, but can you code it?

Primary LanguageC

ft_printf

"Because i’m tired of using putnbr and putstr"

Score

"The key to a successful ft_printf is a well-structured and good extensible code."

💡 Description 💡

Coding legendary printf function from standard ANCI C library.

Conversions included:

Specifier %c %s %p %d %i %o %u %x %X %f %%

Flags included:

Flags hh h l ll L # 0 - + ' '

Here is the basic format of how you can use ft_printf specifiers:
%[$][flags][width][.precision][length modifier]conversion

🛠 Usage 🛠

In the root of the repository, you have the Makefile, which will handle the compiling of the library.

  1. At the root of the repository simply run make. This will compile the library and the name will be libprintf.a

  2. To use the ft_printf simply compile your .c file/files and the libprintf.a.

/* main.c */
#include "./includes/ft_printf.h"

int main(void)
{
    ft_printf("Hello World!\n");
}
gcc main.c libprintf.a
./a.out
Hello World!

👷🏽 Testing 👷🏽

Makefile can be used to test ft_printf simply run:
make test
This will create two files at the root of the repository 1.printf.txt 2.ft_prinft.txt

You can either use BASH command diff to compare two files
diff printf.txt ft_prinft.txt
But better way is the use VScode feature compare selected:

testing.mov

More tests can be added to main.c file. This can be found in eval_tests/ folder.

PDF

PDF of the subject

Keywords

  • Project scalability
  • Reverse engineering
  • Variadic functions
  • Dispatcher/Jump table in C
  • Array of function pointers