This project is my first coopriton project in ALX learning program can't wait to start!
We are goning to make out own C printf function.
My partner here is MOHAMedelhennawy we are going to start to work in the project at 18 Aug 2023
We started by cloning the repo
git clone
Uploded our very first README.md file
vim README.md
And now we are wating for the project to start
the main fincion which contaiians all the other function to work togther as one
int _printf(const char *format, ...)
{
form arr[] = {
{'s', print_str}, {'c', print_char},
{'i', print_INT}, {'d', print_INT},
{'b', print_binary}, {'o', print_oct},
{'x', print_hex}, {'X', print_HEX},
{'u', print_unsigned}, {'S', print_string},
{'r', print_rev}, {'R', print_rot},
{'%', print_percent}, {'\0', NULL}};
int i = 0, len = 0, sum = 0, flag;
va_list List;
if (format == NULL || (format[0] == '%' && format[1] == '\0'))
return (-1);
va_start(List, format);
while (format[i] != '\0')
{
if (format[i] == '%')
{
i++;
flag = search_f(format[i], "scidboxXuSrR%");
if (flag >= 0)
{
len += arr[flag].fun(List);
sum += 2;
i++;
}
else
_putchar('%');
}
else
{
_putchar(format[i]);
i++;
}
}
va_end(List);
return (i + len - sum);
}
Checks if the % specfire is avlible in the funtion or not
int search_f(char f, char *c)
{
int i;
for (i = 0; c[i] != '\0'; i++)
{
if (c[i] == f)
return (i);
}
return (-1);
}
Our main output function which uses write keyword to wrint in the standerd output stream
int _putchar(int s)
{
return (write(1, &s, 1));
}```