-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Iva edited this page Sep 27, 2024
·
7 revisions
This project is part of the 42 curriculum and serves as the foundation for understanding fundamental C programming concepts. The goal of this project is to recreate the formatting functionality provided by printf, handling strings, numbers, characters, and managing various argument types and conversions. Explore the documentation to learn how each function works and how to integrate them into your projects.
/printf │ ├── /inc │ └── ft_printf.h │ ├── /src │ ├── ft_printf.c │ ├── hex.c │ ├── pointer.c │ ├── unsig.c │ └── utils.c │ └── Makefile
/inc
: This directory contains the project header file.
/src
: This directory contains the project's source code files.
General | Utils | |
---|---|---|
ft_printf |
print_hex_varargs , print_pointer , print_unsig
|
ck_format ,print_hex_rec , unsig_number , ft_putchar_v2 , ft_putstr_v2 , ft_putnbr_v2
|
- The functions under the General category contain the primary function for formatted output. The key function,
ft_printf
, reimplements the standardprintf
function in C, providing the ability to handle formatted output for different data types. It processes a variadic list of arguments and uses format specifiers like%d
,%s
, and%x
to format strings, integers, and hexadecimal numbers.
- The Print category focuses on printing specific types of data, such as hexadecimal numbers, pointers, and unsigned integers. Functions like
print_hex_varargs
allow numbers to be printed in hexadecimal format, handling both lowercase and uppercase letters based on the format specifier. - The
print_pointer
function converts and prints a memory address in hexadecimal format, prefixed with0x
, whileprint_unsig
is responsible for printing unsigned integers. These functions are essential for handling specific formatting tasks that extend the functionality offt_printf
.
- The Utility category provides helper functions that support the main printing and formatting operations.
- Functions like
ck_format
are used to interpret the format specifiers passed toft_printf
, determining the correct output format for each argument.print_hex_rec
is used to recursively convert and print numbers in hexadecimal format, whileunsig_number
calculates the number of digits in an unsigned integer, allowing for precise formatting. - Additionally, utility functions like
ft_putchar_v2
,ft_putstr_v2
, andft_putnbr_v2
handle basic output operations, printing single characters, strings, and numbers to the standard output, respectively.