@@ -15,12 +15,14 @@ int _printf(const char * const format, ...)
|
|||||||
{"%S", printf_exclusive_string}, {"%p", printf_pointer}
|
{"%S", printf_exclusive_string}, {"%p", printf_pointer}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* init list*/
|
||||||
va_list args;
|
va_list args;
|
||||||
int i = 0, j, len = 0;
|
int i = 0, j, len = 0;
|
||||||
|
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
if (format == NULL || (format[0] == '%' && format[1] == '\0'))
|
if (format == NULL || (format[0] == '%' && format[1] == '\0'))
|
||||||
return (-1);
|
return (-1);
|
||||||
|
/*jump*/
|
||||||
Here:
|
Here:
|
||||||
while (format[i] != '\0')
|
while (format[i] != '\0')
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* _putchar - print character
|
* _putchar - print character
|
||||||
* @c: character
|
* @c: character
|
||||||
*
|
*
|
||||||
* Return: 1 idk
|
* Return: 1
|
||||||
*/
|
*/
|
||||||
int _putchar(char c)
|
int _putchar(char c)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
/**
|
/**
|
||||||
* printf_exclusive_string - print exclusuives string.
|
* printf_exclusive_string - print exclusuives string.
|
||||||
* @val: argumen t.
|
* @val: argument.
|
||||||
* Return: the length of the string.
|
* Return: the length of the string.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -18,6 +18,7 @@ int printf_exclusive_string(va_list val)
|
|||||||
{
|
{
|
||||||
if (s[i] < 32 || s[i] >= 127)
|
if (s[i] < 32 || s[i] >= 127)
|
||||||
{
|
{
|
||||||
|
/* speical */
|
||||||
_putchar('\\');
|
_putchar('\\');
|
||||||
_putchar('x');
|
_putchar('x');
|
||||||
len = len + 2;
|
len = len + 2;
|
||||||
@@ -27,6 +28,7 @@ int printf_exclusive_string(va_list val)
|
|||||||
_putchar('0');
|
_putchar('0');
|
||||||
len++;
|
len++;
|
||||||
}
|
}
|
||||||
|
/* epic hex */
|
||||||
len = len + printf_HEX_aux(cast);
|
len = len + printf_HEX_aux(cast);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
4
main.h
4
main.h
@@ -1,6 +1,8 @@
|
|||||||
#ifndef MAIN_H
|
#ifndef MAIN_H
|
||||||
#define MAIN_H
|
#define MAIN_H
|
||||||
|
|
||||||
|
/* important libs */
|
||||||
|
/* they bussin frfr*/
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -8,7 +10,7 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct format - match the conversion specifiers
|
* struct format - conversion specifiers
|
||||||
* @id:identifier
|
* @id:identifier
|
||||||
* @f: type pointer
|
* @f: type pointer
|
||||||
*/
|
*/
|
||||||
|
|||||||
13
proven-point/tests/hextest.c
Normal file
13
proven-point/tests/hextest.c
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#include "../main.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* main - later ig
|
||||||
|
*
|
||||||
|
* Return: DEATH
|
||||||
|
*/
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
_printf("%x", 0x0f);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* printf_dec - prints decimal
|
* printf_dec - decimal
|
||||||
* @args: argument to print
|
* @args: argument rint
|
||||||
* Return: number of characters printed
|
* Return: number of characters printed
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int printf_dec(va_list args)
|
int printf_dec(va_list args)
|
||||||
{
|
{
|
||||||
|
/* initvars*/
|
||||||
int n = va_arg(args, int);
|
int n = va_arg(args, int);
|
||||||
int num, last = n % 10, digit;
|
int num, last = n % 10, digit;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|||||||
12
special.c
12
special.c
@@ -1,6 +1,6 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
/**
|
/**
|
||||||
* printf_37 - prints the char 37.
|
* printf_37 - prints %
|
||||||
* Return: 1.
|
* Return: 1.
|
||||||
*/
|
*/
|
||||||
int printf_37(void)
|
int printf_37(void)
|
||||||
@@ -10,16 +10,18 @@ int printf_37(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* printf_rot13 - printf str to ROT13 place into buffer
|
* printf_rot13 - ROT13 CAESAR's AMAZING CIPHEER
|
||||||
* @args: type struct va_arg where is allocated printf arguments
|
* @args: STRING
|
||||||
* Return: counter
|
* Return:coun
|
||||||
*/
|
*/
|
||||||
int printf_rot13(va_list args)
|
int printf_rot13(va_list args)
|
||||||
{
|
{
|
||||||
int i, j, counter = 0;
|
int i, j, counter = 0;
|
||||||
int k = 0;
|
int k = 0;
|
||||||
char *s = va_arg(args, char*);
|
char *s = va_arg(args, char*);
|
||||||
|
/* basic alphabet */
|
||||||
char alpha[] = {"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"};
|
char alpha[] = {"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"};
|
||||||
|
/* shifted by 13 */
|
||||||
char beta[] = {"nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM"};
|
char beta[] = {"nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM"};
|
||||||
|
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
@@ -46,7 +48,7 @@ int printf_rot13(va_list args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* printf_pointer - prints an hexgecimal number.
|
* printf_pointer - prints an hexdecimal number.
|
||||||
* @val: arguments.
|
* @val: arguments.
|
||||||
* Return: counter.
|
* Return: counter.
|
||||||
*/
|
*/
|
||||||
|
|||||||
15
strings.c
15
strings.c
@@ -1,9 +1,9 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* printf_char - prints a char.
|
* printf_char - char.
|
||||||
* @val: arguments.
|
* @val: args
|
||||||
* Return: 1.
|
* Return: 1
|
||||||
*/
|
*/
|
||||||
int printf_char(va_list val)
|
int printf_char(va_list val)
|
||||||
{
|
{
|
||||||
@@ -15,12 +15,13 @@ int printf_char(va_list val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* printf_bin - prints a binary number.
|
* printf_bin - binary number.
|
||||||
* @val: arguments.
|
* @val: arguments.
|
||||||
* Return: 1.
|
* Return: 1
|
||||||
*/
|
*/
|
||||||
int printf_bin(va_list val)
|
int printf_bin(va_list val)
|
||||||
{
|
{
|
||||||
|
/* inits */
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
int cont = 0;
|
int cont = 0;
|
||||||
int i, a = 1, b;
|
int i, a = 1, b;
|
||||||
@@ -47,7 +48,7 @@ int printf_bin(va_list val)
|
|||||||
return (cont);
|
return (cont);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* printf_HEX - prints an hexgecimal number.
|
* printf_HEX - prints an hexdecimal number.
|
||||||
* @val: arguments.
|
* @val: arguments.
|
||||||
* Return: counter.
|
* Return: counter.
|
||||||
*/
|
*/
|
||||||
@@ -82,8 +83,6 @@ int printf_HEX(va_list val)
|
|||||||
return (counter);
|
return (counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* printf_HEX_aux - prints an hexdecimal number.
|
* printf_HEX_aux - prints an hexdecimal number.
|
||||||
* @num: number to print.
|
* @num: number to print.
|
||||||
|
|||||||
18
strs2.c
18
strs2.c
@@ -1,7 +1,7 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
/**
|
/**
|
||||||
* _strlen - Returns the lenght of a string.
|
* _strlen - Returns the length.
|
||||||
* @s: Type char pointer
|
* @s: char pointer
|
||||||
* Return: c.
|
* Return: c.
|
||||||
*/
|
*/
|
||||||
int _strlen(char *s)
|
int _strlen(char *s)
|
||||||
@@ -14,8 +14,8 @@ int _strlen(char *s)
|
|||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* _strlenc - Strlen function but applied for constant char pointer s
|
* _strlenc - char pointer
|
||||||
* @s: Type char pointer
|
* @s: char pointer
|
||||||
* Return: c
|
* Return: c
|
||||||
*/
|
*/
|
||||||
int _strlenc(const char *s)
|
int _strlenc(const char *s)
|
||||||
@@ -29,7 +29,7 @@ int _strlenc(const char *s)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* printf_string - print a string.
|
* printf_string - print a string.
|
||||||
* @val: argumen t.
|
* @val: argument.
|
||||||
* Return: the length of the string.
|
* Return: the length of the string.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -57,9 +57,9 @@ int printf_string(va_list val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* printf_unsigned - prints integer
|
* printf_unsigned - integer
|
||||||
* @args: argument to print
|
* @args: argument
|
||||||
* Return: number of characters printed
|
* Return: number of chars printed
|
||||||
*/
|
*/
|
||||||
int printf_unsigned(va_list args)
|
int printf_unsigned(va_list args)
|
||||||
{
|
{
|
||||||
@@ -102,7 +102,7 @@ int printf_unsigned(va_list args)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* printf_srev - function that prints a str in reverse
|
* printf_srev - function that prints a str in reverse
|
||||||
* @args: type struct va_arg where is allocated printf arguments
|
* @args: va_arg arguments
|
||||||
* Return: the string
|
* Return: the string
|
||||||
*/
|
*/
|
||||||
int printf_srev(va_list args)
|
int printf_srev(va_list args)
|
||||||
|
|||||||
Reference in New Issue
Block a user