/ft_printf

Recode libc's printf function

Primary LanguageC

ft_printf

Recode C Standard Library function printf().

Now part of my personal libft library, used for output and visualizers for further C projects (Push_swap, Lem_in, Corewar, & md5)

See the subject for more details.

Final Score 112/100

Getting Started

First clone this repo.
git clone https://github.com/dfinnis/ft_printf.git; cd ft_printf

Make to compile libftprintf.a.
make

Include inc/ft_printf.h at the top of a C file, then you can use ft_printf just like printf.

Example

Let's create an example test.c at the root of this project.

#include "inc/ft_printf.h"
#include <stdio.h>

int main(void)
{
	ft_printf("%s, %s!\n", "Oh", "Hi!");
	printf("%s, %s!\n", "Oh", "Hi!");
	return (0);
}

Compile test.c with libftprintf.a includes, and run.
gcc test.c libftprintf.a -I includes -o test; ./test

Parameters

The number of parameters is indefinite (variadic arguments were used). ft_printf has the following functionality:

  • Conversions: c, s, p, d, i, o, O, u, U, x, X, f, %%, b (binary)
  • Style flags: #, 0, -, +, space, *
  • Conversion flags: hh, h, l, ll, L, z, j
  • Manage minimum field-width
  • Manage precision

Team

I wrote this project in a team with the wonderful @svaskeli