Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/amaitou/ft_printf
Recoding of the c standard function printf()
https://github.com/amaitou/ft_printf
1337school 42cursus 42network printf-42 variadic-functions
Last synced: 8 days ago
JSON representation
Recoding of the c standard function printf()
- Host: GitHub
- URL: https://github.com/amaitou/ft_printf
- Owner: amaitou
- Created: 2022-10-16T13:05:32.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-01-31T02:43:19.000Z (10 months ago)
- Last Synced: 2024-01-31T03:46:03.820Z (10 months ago)
- Topics: 1337school, 42cursus, 42network, printf-42, variadic-functions
- Language: C
- Homepage:
- Size: 25.4 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
---
![Quotation-Aristotle-Be-a-free-thinker-and-don-t-accept-everything-you-139-75-05](https://user-images.githubusercontent.com/49293816/210186768-6aa77841-e766-4296-b995-7124b7861d36.jpeg)---
# Ft_printfThis is the second project of the **`42Cursus`**.
The goal of this project is pretty straightforward. recoding `printf()` (not the whole function).**``` Note: I haven't shared the PDF of this project, as well as, I haven't explained anything due to school privacy reasons!```**
This project consists of two parts:
- **Mandatory part**
- **Bonus Part**> Note: The **Bonus Part** is not that necessary to validate the project, but it gives some extra XPs and days for the **` The Blackhole`**.
---
# Project Structure
```
|____.gitignore
|____includes
| |____ft_printf.h
|____Makefile
|____README.md
|____sources
| |____ft_printf.c
| |____ft_printhex.c
| |____ft_putchar.c
| |____ft_putsigned.c
| |____ft_putstr.c
| |____ft_putunsigned.c
```---
# Mandatory Part
To implement your own `printf()` you need to go over each one of these string formats:
- `%c` Prints a single character.
- `%s` Prints a string (as defined by the common C convention).
- `%p` The void * pointer argument has to be printed in hexadecimal format.
- `%d` Prints a decimal (base 10) number.
- `%i` Prints an integer in base 10.
- `%u` Prints an unsigned decimal (base 10) number.
- `%x` Prints a number in hexadecimal (base 16) lowercase format.
- `%X` Prints a number in hexadecimal (base 16) uppercase format.
•-`%%` Prints a percent sign.
---# What are variadic functions
To have this project done you must learn a new `C Concept` which is **`Variadic Functions`**.
in `C Programming Language` function takes a known number of params to deal with, but what if we want to pass an unknown number of params and let the function handle all of them? it's cool right :)?
_with `Variadic Functions` this problem would be fixed._
Here is how to declare a `Variadic Function` that takes a variable number of params:
```c
void variadic_function(char *s, ...)
```let's break this example down so we can see what this weird function does.
first of all, this function returns nothing, the first parameter is a string but the second one `...` is something to declare to the function that we are about to accept a variable number of params.
learn more about `Variadic Functions` via [`Variadic Functions in c`](https://www.geeksforgeeks.org/variadic-functions-in-c/#:~:text=Variadic%20functions%20are%20functions%20that,of%20arguments%20can%20be%20passed.)
---
# Things you will learn in this project
> Variadic Functions
> Number System Conversion
> Implementation of your own `printf()` function
> Makefile
> How to use `printf()` properly
> Pointers
---
## Contact Me* [Twitter][_1]
[_1]: https://twitter.com/amait0u