https://github.com/xdec0de/42printf
[42] My own (Very limited) version of printf
https://github.com/xdec0de/42printf
42 42born2code 42cursus 42school c ftprintf ftprintf42 printf printf42
Last synced: about 1 month ago
JSON representation
[42] My own (Very limited) version of printf
- Host: GitHub
- URL: https://github.com/xdec0de/42printf
- Owner: xDec0de
- License: mit
- Created: 2021-11-26T14:34:33.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-26T16:14:37.000Z (5 months ago)
- Last Synced: 2025-02-02T10:34:54.222Z (3 months ago)
- Topics: 42, 42born2code, 42cursus, 42school, c, ftprintf, ftprintf42, printf, printf42
- Language: C
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 42 - ft_printf
A project that consists on creating a replica of the `printf` function.
Well... A very limited version of it.## Project instructions
First, let's see the general instructions that apply to ft_printf:
- The Makefile must not relink (Unnecesary recompilations).
- The function must never crash nor have undefined behavior
(This project has an exception to this rule).
- The code must be written following
[norminette](https://github.com/42School/norminette) requirements.
- Memory leaks are an issue, so no leaks are allowed, even
if the function fails.Now, the specific instructions for ft_printf:
- The only allowed to use functions are `malloc`, `free`, `write`,
`va_start`, `va_arg`, `va_copy` and `va_end`.
- The behavior of `printf` must be replicated, so if `printf` crashes,
this function should crash too, the return value must also be the same.
- The use of [libft](https://github.com/xDec0de/42libft) is allowed.
But I decided to use new functions.
- ONLY the following conversions must be handled:
%c, %s, %p, %d, %i, %u, %x, %X and %%## What I learned
This project teaches us how to use variable arguments with
`va_start`, `va_arg`, `va_copy` and `va_end`.
Even though I didn't need to use `va_copy`.## Testing the project
This project includes a test file, `test_printf.c`. You can compile all
files with something like `gcc *.c` and run the executable to see if this
project behaves exactly as the `printf` function. This cannot be compiled
with error flags as it intentionally uses weird values.~ This file is ignored by Codacy, as it has intentionally bad code
quality. This was a fast solution, a proper tester is preferred over it.