Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/servettonga/ft_printf
A library that contains ft_printf, a function that mimics the real printf.
https://github.com/servettonga/ft_printf
clang clanguage cpp printf
Last synced: about 12 hours ago
JSON representation
A library that contains ft_printf, a function that mimics the real printf.
- Host: GitHub
- URL: https://github.com/servettonga/ft_printf
- Owner: servettonga
- Created: 2024-01-09T19:51:45.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-01-10T13:27:07.000Z (9 days ago)
- Last Synced: 2025-01-10T14:28:17.892Z (9 days ago)
- Topics: clang, clanguage, cpp, printf
- Language: C
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ft_printf
A custom implementation of the C standard library printf function with support for basic format specifiers and flags.
## Overview
This project recreates printf's core functionality without using the buffer management of the original printf. It handles the most common format specifiers and formatting flags.
## Features
### Format Specifiers
| Specifier | Description |
|-----------|-------------|
| %c | Single character |
| %s | String of characters |
| %p | Pointer address in hex |
| %d | Decimal (base 10) integer |
| %i | Integer in base 10 |
| %u | Unsigned decimal integer |
| %x | Hex integer (lowercase) |
| %X | Hex integer (uppercase) |
| %% | Percent sign |### Flags
| Flag | Description |
|------|-------------|
| - | Left-justify within field width |
| + | Force plus/minus sign |
| (space) | Space if no sign |
| # | 0x/0X prefix for hex |
| 0 | Zero padding |
| . | Precision |
| width | Minimum field width |## Usage
```c
#include "ft_printf.h"int main(void)
{
// Basic string
ft_printf("Hello %s!\n", "world");
// Multiple formats
ft_printf("Num: %d, Hex: %x, Char: %c\n", 42, 42, 'A');
// Using flags
ft_printf("Padded: %05d\n", 42);
ft_printf("Left-aligned: %-10s\n", "text");
return (0);
}
```## Notes
- Buffer management is not implemented as per project requirements
- All memory allocations are properly handled and freed
- The project follows 42 school's coding standards