Skip to content

andrelmbackman/ft_printf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ft_printf

Implementation of printf, dprintf and asprintf.

To test:

1. run Make at the root of the repository
2. include "ft_printf.h" in your main .c-file
3. compile your file with libftprintf.a

example: [ gcc your_file.c libftprintf.a -I./includes ]

Conversions

  • %c: character
  • %d, %i: integer
  • %s: string
  • %p: pointer
  • %x, %X: hexadecimal
  • %o, %O: octal
  • %u: unsigned integer
  • %f: float

Flags:

Flag Description
0 zero-pad
[number] width
+ attach a '+'-sign to positive numbers
-[number] left-justified width
* specify the value as one of the variable arguments
. precision
[space] pad non-negative numbers with one space character

Bonuses that C library printf does not handle:

colours:

  • eoc(end of colour)
  • red
  • green
  • blue
  • yellow
  • purple
  • cyan
  • black
  • white

Screen Shot 2022-04-27 at 4 24 41 PM

Screen Shot 2022-04-27 at 4 25 36 PM

%b-conversion:

  • Coverts an unsigned integer into binary string, add a number after a dot for precision (zero padding).

Screen Shot 2022-04-29 at 5 53 41 PM

Screen Shot 2022-04-29 at 5 54 19 PM

Screen Shot 2022-04-27 at 4 18 29 PM

Screen Shot 2022-04-27 at 4 18 11 PM

Banker's rounding on floats and doubles.

About

Implementation of printf, dprintf and asprintf.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published