Correction Makefile et suppression 'y' inutile et allègement du code
This commit is contained in:
parent
95b7ca347f
commit
1822beefff
2
Makefile
2
Makefile
|
@ -10,7 +10,7 @@
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
SRCS = ft_get_size.c ft_itoa.c ft_power.c ft_printf.c ft_putchar.c ft_putnbr.c \
|
SRCS = ft_get_size.c ft_power.c ft_printf.c ft_putchar.c ft_putnbr.c \
|
||||||
ft_putnbrhex.c ft_putnbrhex_upper.c ft_putstr.c ft_putunbr.c ft_putvd.c
|
ft_putnbrhex.c ft_putnbrhex_upper.c ft_putstr.c ft_putunbr.c ft_putvd.c
|
||||||
OBJS = ${SRCS:.c=.o}
|
OBJS = ${SRCS:.c=.o}
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
|
@ -65,26 +65,24 @@ int ft_printf(const char *str, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
int i;
|
int i;
|
||||||
int y;
|
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
va_start(args, str);
|
va_start(args, str);
|
||||||
i = -1;
|
i = 0;
|
||||||
y = 0;
|
|
||||||
count = 0;
|
count = 0;
|
||||||
while (str[++i])
|
while (str[i])
|
||||||
{
|
{
|
||||||
if (str[i] == '%' && ft_is_format(str[i + 1]))
|
if (str[i] == '%' && ft_is_format(str[i + 1]))
|
||||||
{
|
{
|
||||||
count += ft_post_character(str[i + 1], args);
|
count += ft_post_character(str[i + 1], args);
|
||||||
i++;
|
i++;
|
||||||
y++;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ft_putchar(str[i]);
|
ft_putchar(str[i]);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return (count);
|
return (count);
|
||||||
|
|
|
@ -24,7 +24,7 @@ int ft_power(int nb, int power);
|
||||||
int ft_get_size(long long n);
|
int ft_get_size(long long n);
|
||||||
int ft_putnbr(int n);
|
int ft_putnbr(int n);
|
||||||
int ft_putunbr(unsigned int n);
|
int ft_putunbr(unsigned int n);
|
||||||
int ft_putnbrhex(unsigned int v);
|
int ft_putnbrhex(unsigned long v);
|
||||||
int ft_putnbrhex_upper(unsigned int v);
|
int ft_putnbrhex_upper(unsigned int v);
|
||||||
int ft_putvd(void *v);
|
int ft_putvd(void *v);
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
#include "ft_printf.h"
|
#include "ft_printf.h"
|
||||||
|
|
||||||
int ft_putnbrhex(unsigned int v)
|
int ft_putnbrhex(unsigned long v)
|
||||||
{
|
{
|
||||||
int tmp;
|
int tmp;
|
||||||
int count;
|
int count;
|
||||||
|
|
25
ft_putvd.c
25
ft_putvd.c
|
@ -12,29 +12,6 @@
|
||||||
|
|
||||||
#include "ft_printf.h"
|
#include "ft_printf.h"
|
||||||
|
|
||||||
static int ft_putnbrhexull(unsigned long v)
|
|
||||||
{
|
|
||||||
int tmp;
|
|
||||||
int count;
|
|
||||||
char hex[100];
|
|
||||||
|
|
||||||
count = 0;
|
|
||||||
tmp = 0;
|
|
||||||
while (v != 0)
|
|
||||||
{
|
|
||||||
tmp = v % 16;
|
|
||||||
if (tmp < 10)
|
|
||||||
hex[count++] = tmp + 48;
|
|
||||||
else
|
|
||||||
hex[count++] = tmp + 87;
|
|
||||||
v = v / 16;
|
|
||||||
}
|
|
||||||
tmp = count - 1;
|
|
||||||
while (tmp >= 0)
|
|
||||||
ft_putchar(hex[tmp--]);
|
|
||||||
return (count);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ft_putvd(void *v)
|
int ft_putvd(void *v)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
|
@ -45,6 +22,6 @@ int ft_putvd(void *v)
|
||||||
u = (unsigned long)v;
|
u = (unsigned long)v;
|
||||||
count = 2;
|
count = 2;
|
||||||
ft_putstr("0x");
|
ft_putstr("0x");
|
||||||
count += ft_putnbrhexull(u);
|
count += ft_putnbrhex(u);
|
||||||
return (count);
|
return (count);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue