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.
- Host: GitHub
- URL: https://github.com/abderrsfa/ft_printf
- Owner: AbderrSfa
- License: apache-2.0
- Created: 2020-10-14T09:02:32.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-08-09T16:46:38.000Z (over 4 years ago)
- Last Synced: 2025-05-18T05:08:09.260Z (8 months ago)
- Topics: 1337, 42born2code, character, ft-printf, hexadecimal, libftprintf, precision, printf
- Language: C
- Homepage:
- Size: 43 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)