49 lines
1.3 KiB
Markdown
49 lines
1.3 KiB
Markdown
# ft_printf
|
|
|
|
Your own implementation of the printf function from libc.
|
|
|
|
## 💡 About
|
|
|
|
The ft_printf project consists of programming your own version of the famous printf function. You will learn about variadic arguments and will implement formatted output conversion. This project is a great way to improve your programming skills and is frequently reused in subsequent 42 projects.
|
|
|
|
## 🛠️ Supported Conversions
|
|
|
|
The function handles the following conversions:
|
|
- `%c` - Single character
|
|
- `%s` - String
|
|
- `%p` - Pointer address
|
|
- `%d` - Decimal (base 10) integer
|
|
- `%i` - Integer in base 10
|
|
- `%u` - Unsigned decimal (base 10) integer
|
|
- `%x` - Hexadecimal (base 16) integer lowercase
|
|
- `%X` - Hexadecimal (base 16) integer uppercase
|
|
- `%%` - Percentage sign
|
|
|
|
## 📋 Usage
|
|
|
|
```c
|
|
#include "ft_printf.h"
|
|
|
|
int main(void)
|
|
{
|
|
ft_printf("Hello %s!\n", "world");
|
|
ft_printf("Number: %d\n", 42);
|
|
ft_printf("Hexadecimal: %x\n", 42);
|
|
return (0);
|
|
}
|
|
```
|
|
|
|
## ⚠️ Function Prototype
|
|
|
|
```c
|
|
int ft_printf(const char *format, ...);
|
|
```
|
|
|
|
Returns the number of characters printed (excluding the null byte used to end output to strings).
|
|
|
|
## 📊 Expected Output
|
|
|
|
The function should work exactly like the original printf, handling all the specified conversions correctly.
|
|
|
|
---
|