Because putnbr and putstr aren't enough
This project is pretty straight forward. You will recode printf. You will mainly learn how to use variadic arguments.
This project consists of coding a library that contains a simplified version of the printf function, implementing basic format specifiers and learning how to handle variadic arguments in C.
Implemented specifiers:
%c- Character%s- String%p- Pointer address%d- Decimal integer%i- Integer%u- Unsigned decimal%x- Hexadecimal (lowercase)%X- Hexadecimal (uppercase)%%- Percent sign
The function is written in C language and thus needs the gcc compiler and some standard C libraries to run.
1. Compiling the library
To compile, go to the library path and run:
$ make2. Using it in your code
To use the library functions in your code, simply include its header:
#include "ft_printf.h"Example usage:
#include "ft_printf.h"
int main(void)
{
ft_printf("Hello %s!\n", "world");
ft_printf("Number: %d\n", 42);
ft_printf("Hex: %x\n", 255);
return (0);
}You can use this third party tester to fully test the project:
ft_printf.c- Main printf function implementationft_printf.h- Header file with function prototypesft_putchar.c- Character output functionft_puthex.c- Hexadecimal output functionsft_putnbr.c- Number output functionsft_putstr.c- String output functionMakefile- Compilation rules