Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pin3dev/42_ft_printf
Replicates standard printf function in C. This project deepens understanding of variadic functions, data formatting, and low-level I/O management.
https://github.com/pin3dev/42_ft_printf
42-cursus 42-school 42born2code custom-library format-specifiers libc printf printf-42 varargs variadic-function
Last synced: about 19 hours ago
JSON representation
Replicates standard printf function in C. This project deepens understanding of variadic functions, data formatting, and low-level I/O management.
- Host: GitHub
- URL: https://github.com/pin3dev/42_ft_printf
- Owner: pin3dev
- Created: 2024-08-08T15:49:14.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-10-24T23:23:26.000Z (13 days ago)
- Last Synced: 2024-10-26T09:28:14.146Z (11 days ago)
- Topics: 42-cursus, 42-school, 42born2code, custom-library, format-specifiers, libc, printf, printf-42, varargs, variadic-function
- Language: C
- Homepage:
- Size: 62.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
ft_Printf
Introduction •
Structure •
Docs •
Cloning •
Usage •
Norms •
Theoretical
This repository contains the implementation of a custom **printf** function, part of a coding project for the **42 School** program.
The goal of the **ft_printf** project is to recreate the functionality of the standard C **printf** function. This involves handling strings, type conversions, and output formatting in a versatile manner, allowing for a deeper understanding of the internal workings of this common function.
This implementation supports various format specifiers and data types, making it useful for future projects that cannot rely on the standard C library.
The structure of the project focuses on creating a main function, **ft_printf**, which can handle different data types and formatting, such as **strings**, **integers**, **characters**, and **hexadecimals**. The project is composed of several auxiliary functions that manipulate and format these data types as needed.
For detailed documentation, including usage examples, please visit the link below:
To clone this repository and compile the project, run the following commands:
```bash
git clone https://github.com/pin3dev/42_ft_Printf.git
cd 42_ft_Printf/printf
```
This will download the project from GitHub into your local machine in current directory. Once inside the `printf` directory, you must run make to compile the library.### Makefile
A `Makefile` is provided to automate the compilation process. It includes the following rules:
- `all`: Compiles the library and generates the `libftprintf.a` file.
- `clean`: Removes object files.
- `fclean`: Removes object files and the library.
- `re`: Recompiles the entire project.
- `test`: Compiles the project and runs the test stored in `test/main.c`To compile the library, simply run:
```bash
make
```This will generate the `libftprintf.a` library, which can be linked in other projects to use the **ft_printf** function.
### Basic Usage
To use the **ft_printf** library in your C code, follow the steps below:
1. Include the header in your code:
```c
#include "42_ft_Printf/printf/inc/ft_printf.h"
```2. Compile your code with the library:
```bash
cc -Wall -Wextra -Werror -o your_exec your_code.c -L 42_ft_Printf/printf/ -lftprintf -L 42_Libft/libft/ -lft
```3. You can now use the `ft_printf` function in your program as follows:
```c
ft_printf("Hello, %s! The number is %d.\n", "world", 42);
```## ⚠️ Norms and Guidelines Disclaimer
This project strictly follows the [**42 School Norm**](https://github.com/pin3dev/42_Cursus/blob/b9cd0fe844ddb441d0b3efb98abcee92aee49535/assets/General/norme.en.pdf) coding guidelines, which significantly influenced certain decisions in its implementation. These rules may sometimes lead to seemingly inefficient or unusual solutions, but they were necessary to meet the strict requirements of the school.
All the theoretical material used to develop this project is organized and can be accessed directly via the link below: