ygor-sena / 42cursus-ft-printf

The third project of 42 curriculum asks students to reproduce some features of the famous printf() function.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OS Language Grade Status

📣 Introduction

This project is pretty straightforward. It asks students to recode printf() in order to make them learn about how a variadic function works. It also aims to make students think about how they are going to implement the project. After all, the key to a successful ft_printf is a well-structured and extensible code.

Inside the folder ft-printf-studies there is a file that test all the possible combinations of printf flags.

✨ Implemented features

Mandatory

  • ✅ The function has to implement the following conversions: cspdiuxX%
Conversion Description
c Prints a single character.
s Prints a string (as defined by the common C convention).
p The void * pointer argument has to be printed in hexadecimal format.
d Prints a decimal (base 10) number.
i Prints an integer in base 10.
u Prints an unsigned decimal (base 10) number.
x Prints a number in hexadecimal (base 16) lowercase format.
X Prints a number in hexadecimal (base 16) uppercase format.
% Prints a percent sign.

Bonus 1

  • ❌ Manage any combination of the following flags: -0. and the field minimum width under all conversions.
Flag Description
- Left aligns the argument passed.
0 Add '0' as a padding character in numeric conversions (single space is default).
. Precision definition, followed by a number.

Bonus 2

  • ✅ Manage all the following flags: # + (Yes, one of them is a space).
Flag Description
' ' Adds a single space (' ') in the front of positive numeric conversions.
# Adds the corresponding prefix in front of x and X conversions.
+ Adds a plus sign (+) in the front of positive numeric conversions.

⚒️ How to use the project

Run make or make bonus if you want to compile the mandatory project or the bonus project respectively.

After that, to use the ft_printf() in your project it's necessary to include the library libftprintf.a and the header as follows:

#include "ft_printf.h" 

If you want to include the bonus version, use:

#include "ft_printf_bonus.h" 

Don't forget to add the following flags when compiling your project:

gcc ... -lftprintf -L path/to/libftprintf.a -I path/to/libftprintf.h

📖 References

About

The third project of 42 curriculum asks students to reproduce some features of the famous printf() function.

License:GNU General Public License v3.0


Languages

Language:C 97.8%Language:Makefile 2.2%