An open API service indexing awesome lists of open source software.

https://github.com/abderrsfa/ft_printf

Printf recoded. It manages width, precision, and the '0' '-' '*' flags.
https://github.com/abderrsfa/ft_printf

1337 42born2code character ft-printf hexadecimal libftprintf precision printf

Last synced: 7 months ago
JSON representation

Printf recoded. It manages width, precision, and the '0' '-' '*' flags.

Awesome Lists containing this project

README

          

# 🖨 ft_printf

## 🧐 Description
The aim of this project is pretty straight forward; recode printf. This project teaches the ins and outs of using variadic arguments.
The key to a successful ft_printf is well-structured and extensible code.

## 🔧 Usage
Running `make` will produce a library called ft_printf.a. Use ft_printf() just as you would use printf(). When compiling your code use ft_printf.a.

`gcc main.c ft_printf.a`

## ⚙️ Functionality
Just like the real printf, ft_printf allows the following functionality:

`%[flags][width][.precision]type`

### Flags:
These flags are supported:
- '0' (zero) - if the 'width' option is specified, add zeros to the beginning for numeric types.

- '-' (minus) - Left-align the output of this placeholder.

### Width:
Specifies a minimum number of characters to output.

'\*' : If '\*' is used width is not specified in the format string, but as an additional integer value argument preceding the argument that has to be formatted.

### Precision:
Precision field specifies a maximum limit on the output. E.g: `ft_printf("%.2s", "xyz");` would output 'xy'.

### Type:
These conversion characters are managed:
- %c (character)
- %s (string)
- %p (address)
- %d (digit)
- %i (integer)
- %u (unsigned integer)
- %x (hexadecimal in lowercase)
- %X (hexadecimal in upper case)