Skip to content
Iva edited this page Sep 27, 2024 · 7 revisions

Documentation

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.

Directory Tree

/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.

Logical Groups

General Print 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

General Functions

  • The functions under the General category contain the primary function for formatted output. The key function, ft_printf, reimplements the standard printf 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.

Print Functions

  • 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 with 0x, while print_unsig is responsible for printing unsigned integers. These functions are essential for handling specific formatting tasks that extend the functionality of ft_printf.

Utility Functions

  • 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 to ft_printf, determining the correct output format for each argument. print_hex_rec is used to recursively convert and print numbers in hexadecimal format, while unsig_number calculates the number of digits in an unsigned integer, allowing for precise formatting.
  • Additionally, utility functions like ft_putchar_v2, ft_putstr_v2, and ft_putnbr_v2 handle basic output operations, printing single characters, strings, and numbers to the standard output, respectively.

Next ➡️

Clone this wiki locally