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