https://github.com/adaog0n/42-ft_printf
Developed as part of the 42 school curriculum, this project demonstrates skills in string manipulation, type conversion, and low-level C programming.
https://github.com/adaog0n/42-ft_printf
Last synced: 4 months ago
JSON representation
Developed as part of the 42 school curriculum, this project demonstrates skills in string manipulation, type conversion, and low-level C programming.
- Host: GitHub
- URL: https://github.com/adaog0n/42-ft_printf
- Owner: AdaoG0n
- Created: 2024-10-29T10:59:56.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-11-21T19:12:45.000Z (8 months ago)
- Last Synced: 2025-01-17T02:10:44.578Z (6 months ago)
- Language: C
- Homepage:
- Size: 1.53 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

Testers • Useful Links • Portuguese 🇵🇹To complete the project of recreating the `printf()` function in `C`, follow the steps below:
### 1. Project Structure
Create the Directory Structure:
- A directory for source files `(src/)`.
- A directory for header files `(include/)`.>[!Note]
> I decided to keep everything in the same directory, but it is good practice to separate files into their respective directories.
### 2. Implementing the ft_printf Function
Prototype: Define the function prototype:
```bash
int ft_printf(const char *format, ...);
```Supported Conversions:
- `%c`: character
- `%s`: string
- `%p`: pointer in hexadecimal format
- `%d`: decimal number
- `%i`: integer
- `%u`: unsigned decimal number
- `%x`: hexadecimal number (lowercase)
- `%X`: hexadecimal number (uppercase)
- `%%`: percent symbol
### 3. Handling Variadic Arguments
Use the following functions to handle a variable number of arguments:
- `va_start`
- `va_arg`
- `va_end`
### 4. Creating the Makefile
Create a Makefile with the following rules:
- `NAME`: name of the executable file.
- `all`: compiles all files.
- `clean`: removes temporary files.
- `fclean`: removes all generated files.
- `re`: recompiles everything.Example of a basic `Makefile`:
```bash
makefile
NAME = libftprintf.aSRC = src/ft_printf.c src/utils.c
OBJ = $(SRC:.c=.o)all: $(NAME)
$(NAME): $(OBJ)
ar rcs $@ $^clean:
rm -f $(OBJ)fclean: clean
rm -f $(NAME)re: fclean all
```
### Testing
Create test programs to verify the functionality of your implementation. Test all use cases, including edge cases.
> Below is a list of testers to verify the correct functioning of the project:
| Testers | Author |
| :--------------------------------------------------------------------------------------------------- | :--- |
| [Debugging with main.c](https://github.com/Kuninoto/42_ft_printf/blob/master/lvl_1_ft_printf/main.c) | Kuninoto |
| [francinette](https://github.com/xicodomingues/francinette) | xicodomingues |
| [printfTester](https://github.com/Tripouille/printfTester) | Tripouille |
| [ft_printf_tester](https://github.com/paulo-santana/ft_printf_tester) | paulo-santana |
### Useful Links
| Resource |
| :-------------------------------------------------------------------------------------------------------------------------------------------- |
| [C Tutorial – printf](https://www.codingunit.com/printf-format-specifiers-format-conversions-and-formatted-output) |
| [printf Reference](https://cplusplus.com/reference/cstdio/printf) |
| [IEEE-754 Floating Point Converter](https://www.h-schmidt.net/FloatConverter/IEEE754.html) |
| [Printing Floating-Point Numbers](https://www.ryanjuckett.com/printing-floating-point-numbers) |
| [printf(3) — Linux manual page](https://man7.org/linux/man-pages/man3/printf.3.html) |
| [printf invocation (GNU Coreutils 9.4)](https://www.gnu.org/software/coreutils/manual/html_node/printf-invocation.html#printf-invocation) |
| [Formatted Output (The GNU C Library)](https://www.gnu.org/software/libc/manual/html_node/Formatted-Output.html) |
| [Table of Output Conversions (The GNU C Library)](https://www.gnu.org/software/libc/manual/html_node/Table-of-Output-Conversions.html) |
| [Printing Floating-Point Numbers Quickly and Accurately with Integers](https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf) |>[!Tip]
> Keep your code well-structured and documented.
> Review documentation on variadic functions in C for better understanding.
### Earned Skills


###### Project developed by: [Adão Gonçalves](https://github.com/AdaoG0n)