For the ft_printf project of the 42 school cursus, we must recreate the famous C library printf function. This project teaches us about variadic arguments as well as structures if we plan to implement printf's extra flags.
- Supported conversions: %, c, s, p, i, d, u, x, X
Finished: 04/05/2024 Grade: 100/100.
make or make bonus to compile.
For example, let's create a main.c file.
// Include the header
#include "ft_printf.h"
int main(void)
{
// Call the function
ft_printf("Testing ft_printf!");
return (0);
}Compile the main.c file with the ft_printf library and run the program:
cc main.c libftprintf.a && ./a.outOutput should be:
Testing ft_printf!
The table below lists supported format specifiers:
| Conversion | Short Description |
|---|---|
| %c | Print a single character. |
| %s | Print a string of characters. |
| %p | The void * pointer argument is printed in hexadecimal. |
| %d | Print a decimal (base 10) number. |
| %i | Print an integer in base 10. |
| %u | Print an unsigned decimal (base 10) number. |
| %x | Print a number in hexadecimal (base 16), with lowercase. |
| %X | Print a number in hexadecimal (base 16), with uppercase. |
| %% | Print a percent sign. |