The goal of this project is to recode printf() with a variable number of arguments.
For example, the function can handle the following conversions: cspdiuxX%
For each conversion required by the subject, there's a function that converts the argument and returns the numer of bytes writed:
• %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).
• %% print a percent sign.
Enter the repository with cd and add a "main.c" with touch main.c.
For example copy paste the following code into main:
#include "ft_printf.h"
int main(void)
{
long int hd_big;
long int hd_small;
char *name;
char n[8] = "Heather";
name = &n[0];
hd_big = 590;
hd_small = 590;
ft_printf("Hexa big %X and small %x. Position %p \n", hd_big, hd_small, name);
char *name2;
char n2[10] = "Christian";
char chr;
int age;
int base;
int pos;
long int hd_big2;
long int hd_small2;
name2 = &n2[0];
chr = 'a';
age = 24;
base = 12;
pos = 160;
hd_big2 = 590;
hd_small2 = 590;
ft_printf("My name is %s with an %c saved at: %p. Hexa big %X and small %x. Positive: %u, age %d, %% and %i.\n", name2, chr, name2, hd_big2, hd_small2, pos, age, base);
return (0);
}
Run make (to run the Makefile that will compile the source code and create the library).
You should now see a libftprintf.a file and some object files (.o).
To clean up (removing the .o files), call make clean.
Compile your .c files with gcc using gcc main.c libftprintf.a.
You need to include the libftprintf.a to tell the file which library it is using.
Now you can run the code using ./a.out.
