Skip to content

Commit 6795875

Browse files
author
Mohamed El mouhib
committed
changed some on functions
1 parent e61f9f5 commit 6795875

9 files changed

+37
-31
lines changed

conversions.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
/* ::: :::::::: */
44
/* conversions.c :+: :+: :+: */
55
/* +:+ +:+ +:+ */
6-
/* By: mel-mouh <mel-mouh@student.42.fr> +#+ +:+ +#+ */
6+
/* By: mel-mouh <mel-mouh@student.1337.ma> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2024/11/18 23:07:50 by mel-mouh #+# #+# */
9-
/* Updated: 2024/11/18 23:13:54 by mel-mouh ### ########.fr */
9+
/* Updated: 2024/11/19 22:39:42 by mel-mouh ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#include "libftprintf.h"
13+
#include "ft_printf.h"
1414

1515
int conversions(char spiecifier, va_list args)
1616
{
@@ -33,5 +33,7 @@ int conversions(char spiecifier, va_list args)
3333
count += ft_putunsigned(va_arg(args, unsigned));
3434
else if (spiecifier == '%')
3535
count += ft_putchar('%');
36+
else
37+
return (-1);
3638
return (count);
3739
}

ft_printf.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@
33
/* ::: :::::::: */
44
/* ft_printf.c :+: :+: :+: */
55
/* +:+ +:+ +:+ */
6-
/* By: mel-mouh <mel-mouh@student.42.fr> +#+ +:+ +#+ */
6+
/* By: mel-mouh <mel-mouh@student.1337.ma> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2024/11/16 20:30:02 by mel-mouh #+# #+# */
9-
/* Updated: 2024/11/19 11:43:39 by mel-mouh ### ########.fr */
9+
/* Updated: 2024/11/19 22:41:11 by mel-mouh ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#include "libftprintf.h"
13+
#include "ft_printf.h"
1414

1515
int ft_printf(const char *str, ...)
1616
{
1717
int i;
1818
int count;
1919
va_list args;
2020

21+
if (str == NULL)
22+
return (-1);
2123
va_start(args, str);
2224
i = 0;
2325
count = 0;

libftprintf.h renamed to ft_printf.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/* ************************************************************************** */
22
/* */
33
/* ::: :::::::: */
4-
/* libftprintf.h :+: :+: :+: */
4+
/* ft_printf.h :+: :+: :+: */
55
/* +:+ +:+ +:+ */
6-
/* By: mel-mouh <mel-mouh@student.42.fr> +#+ +:+ +#+ */
6+
/* By: mel-mouh <mel-mouh@student.1337.ma> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2024/11/18 19:04:49 by mel-mouh #+# #+# */
9-
/* Updated: 2024/11/19 11:21:21 by mel-mouh ### ########.fr */
9+
/* Updated: 2024/11/19 22:00:06 by mel-mouh ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#ifndef LIBFTPRINTF_H
14-
# define LIBFTPRINTF_H
13+
#ifndef FT_PRINTF_H
14+
# define FT_PRINTF_H
1515

1616
# include <stdio.h>
1717
# include <unistd.h>

ft_putaddres.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
/* ::: :::::::: */
44
/* ft_putaddres.c :+: :+: :+: */
55
/* +:+ +:+ +:+ */
6-
/* By: mel-mouh <mel-mouh@student.42.fr> +#+ +:+ +#+ */
6+
/* By: mel-mouh <mel-mouh@student.1337.ma> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2024/11/18 19:32:03 by mel-mouh #+# #+# */
9-
/* Updated: 2024/11/18 23:09:52 by mel-mouh ### ########.fr */
9+
/* Updated: 2024/11/19 22:00:54 by mel-mouh ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#include "libftprintf.h"
13+
#include "ft_printf.h"
1414

1515
int ft_putaddres(unsigned long int addr)
1616
{

ft_putchar.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
/* ::: :::::::: */
44
/* ft_putchar.c :+: :+: :+: */
55
/* +:+ +:+ +:+ */
6-
/* By: mel-mouh <mel-mouh@student.42.fr> +#+ +:+ +#+ */
6+
/* By: mel-mouh <mel-mouh@student.1337.ma> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2024/11/18 23:10:38 by mel-mouh #+# #+# */
9-
/* Updated: 2024/11/18 23:10:44 by mel-mouh ### ########.fr */
9+
/* Updated: 2024/11/19 22:00:54 by mel-mouh ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#include "libftprintf.h"
13+
#include "ft_printf.h"
1414

1515
int ft_putchar(char c)
1616
{

ft_putnbr.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
/* ::: :::::::: */
44
/* ft_putnbr.c :+: :+: :+: */
55
/* +:+ +:+ +:+ */
6-
/* By: mel-mouh <mel-mouh@student.42.fr> +#+ +:+ +#+ */
6+
/* By: mel-mouh <mel-mouh@student.1337.ma> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2024/11/18 19:09:59 by mel-mouh #+# #+# */
9-
/* Updated: 2024/11/18 23:11:09 by mel-mouh ### ########.fr */
9+
/* Updated: 2024/11/19 22:00:54 by mel-mouh ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#include "libftprintf.h"
13+
#include "ft_printf.h"
1414

1515
static int leen(int n)
1616
{

ft_putnbrhex.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
/* ::: :::::::: */
44
/* ft_putnbrhex.c :+: :+: :+: */
55
/* +:+ +:+ +:+ */
6-
/* By: mel-mouh <mel-mouh@student.42.fr> +#+ +:+ +#+ */
6+
/* By: mel-mouh <mel-mouh@student.1337.ma> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2024/11/18 19:09:24 by mel-mouh #+# #+# */
9-
/* Updated: 2024/11/18 23:11:38 by mel-mouh ### ########.fr */
9+
/* Updated: 2024/11/19 22:15:37 by mel-mouh ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#include "libftprintf.h"
13+
#include "ft_printf.h"
1414

1515
int ft_putnbr_hex(unsigned long int n, char *hexa)
1616
{
@@ -27,7 +27,7 @@ int ft_putnbr_hex(unsigned long int n, char *hexa)
2727
n /= 16;
2828
}
2929
count = i;
30-
while (i >= 0)
30+
while (i > 0)
3131
ft_putchar(buffer[--i]);
3232
return (count);
3333
}

ft_putstr.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
/* ::: :::::::: */
44
/* ft_putstr.c :+: :+: :+: */
55
/* +:+ +:+ +:+ */
6-
/* By: mel-mouh <mel-mouh@student.42.fr> +#+ +:+ +#+ */
6+
/* By: mel-mouh <mel-mouh@student.1337.ma> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2024/11/18 19:08:39 by mel-mouh #+# #+# */
9-
/* Updated: 2024/11/18 23:11:56 by mel-mouh ### ########.fr */
9+
/* Updated: 2024/11/19 22:04:39 by mel-mouh ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#include "libftprintf.h"
13+
#include "ft_printf.h"
1414

1515
int ft_putstr(char *s)
1616
{
1717
size_t i;
1818

1919
i = 0;
2020
if (s == NULL)
21-
return (-1);
21+
return (ft_putstr("(null)"));
2222
while (s[i] != '\0')
2323
{
2424
write(1, &s[i], 1);

ft_putunsigned.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
/* ::: :::::::: */
44
/* ft_putunsigned.c :+: :+: :+: */
55
/* +:+ +:+ +:+ */
6-
/* By: mel-mouh <mel-mouh@student.42.fr> +#+ +:+ +#+ */
6+
/* By: mel-mouh <mel-mouh@student.1337.ma> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2024/11/18 19:37:27 by mel-mouh #+# #+# */
9-
/* Updated: 2024/11/18 23:12:43 by mel-mouh ### ########.fr */
9+
/* Updated: 2024/11/19 22:29:42 by mel-mouh ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

13-
#include "libftprintf.h"
13+
#include "ft_printf.h"
1414

1515
static int leen(unsigned int n)
1616
{
@@ -30,6 +30,8 @@ int ft_putunsigned(unsigned int n)
3030
int i;
3131

3232
i = leen(n);
33+
if (n == 0)
34+
i += 1;
3335
if (n > 9)
3436
{
3537
ft_putunsigned(n / 10);

0 commit comments

Comments
 (0)