https://github.com/hakolao/ft_printf
Implementation of C standard lib printf
https://github.com/hakolao/ft_printf
Last synced: 1 day ago
JSON representation
Implementation of C standard lib printf
- Host: GitHub
- URL: https://github.com/hakolao/ft_printf
- Owner: hakolao
- Created: 2020-02-25T14:57:51.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-05T11:30:10.000Z (over 4 years ago)
- Last Synced: 2025-01-01T23:09:47.071Z (9 months ago)
- Language: C
- Size: 443 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Printf
Printf from scratch with pure c.
Only following library functions allowed, the rest is from scratch.
- `malloc`
- `free`
- `exit`
- The functions of man 3 `stdarg`## Usage
See e.g: [printf reference](http://www.cplusplus.com/reference/cstdio/printf/)
```
ft_printf("%[flags][width][.precision][length]specifier");
```## Handles
### Variable specs:
```
ndDiuUoOxX
fFeEgG
csp%
b for binary where first bit = sign
```### Formatter specs (sub specs):
```
-+ #0
hhhllljztL
*0-9+.*0-9+
```Does not handle following specs / flags:
```
$: not regonized as flag, ignores whole format and spec if $ is used
aA: not regonized as spec
C(widechar): not regonized as spec
ls(widestring): l is ignored
```### Floats
Float handling follows dragon4 algorithm implemented with guide by [ryanjuckett](http://www.ryanjuckett.com/programming/printing-floating-point-numbers).
- Also assumes little-endian system due to the way I dissect floats, see `libft.h`
This library includes:
- `ft_printf`
- `ft_sprintf`
- `ft_dprintf`Since others have written such extensive tests, I've just ensured this passes all
[42FileChecker](https://github.com/jgigault/42FileChecker) and [PFT](https://github.com/gavinfielder/pft) checks (except unhandled flags, (see above)), and then some.