Because putnbr and putstr aren’t enough
About · Usage · Usefull Command · Testing
This project is pretty straight forward. You will recode printf. Hopefully you will be able to reuse it in future project without the fear of being flagged as a cheater. You will mainly learn how to use variadic arguments.
ft_printf is an individual project at 42 that requires us to create a function similar to the printf from <stdio.h>. The function ft_printf() (the name comes from “print formatted”) prints a string on the screen using a “format string” that includes the instructions to mix several strings and produce the final string to be printed on the screen.
Click here for the interactive link.
- Unix logic
- Rigor
- Unix
- Algorithms & AI
ft_convert
- converts num to related numerical base.ft_putnbr
- prints the number on the screen.ft_putstr
- prints given string on the screen.ft_putchar
- prints given character on the screen.ft_putunbr
- prints given number on the screen (only positive).ft_putptr
- prints given data by hexidecimal numerical base on the screenft_strlen
- computes length of given string.ft_printf
- prints a string on the screen using a “format string” that includes the instructions to mix several strings and produce the final string to be printed on the screen.
Follow the steps below
1. Clone the repository from github
git clone https://github.com/abdulazizabduvakhobov/ft_printf && cd ft_printf/
2. Compile the library by Makefile To compile the library, go to its path and run:
For all mandatory functions:
make
3. Create main.c to test the funtion:
touch main.c
4. Using it in your code
To use the function in your code, simply include its header:
#include "ft_printf.h"
Example of a main
#include "ft_printf.h"
int main(void)
{
ft_printf("%s", "Hello World");
ft_printf("%c", '\n');
ft_printf("%d", 123456789);
ft_printf("%c", '\n');
ft_printf("%X", 987654321);
return (0);
}
/**
* output:
* Hello World
* 123456789
* 3ADE68B1
**/
5.After coding, you have to compile your code with libftprintf.a library like an example below
gcc main.c libftprintf.a -I./sources && ./a.out
# Done :)
The library is written in C language and needs the gcc
compiler and some standard C libraries to run.
1. Cleaning all binary (.o) files
To clean all files generated binary files while doing a make, go to the path and run:
make clean
2. Cleaning all binary (.o) and executable files (.a)
To clean all files generated while doing a make, go to the path and run:
make fclean
2. Checking Norminette standart
To check Norminette errors of all files, simply go to the path and run:
make norm
3. Help command
To get information about command, run:
make help
You can use any of this third party testers to test the project