File tree 9 files changed +37
-31
lines changed
9 files changed +37
-31
lines changed Original file line number Diff line number Diff line change 3
3
/* ::: :::::::: */
4
4
/* conversions.c :+: :+: :+: */
5
5
/* +:+ +:+ +:+ */
6
- /* By: mel-mouh <mel-mouh@student.42.fr> +#+ +:+ +#+ */
6
+ /* By: mel-mouh <mel-mouh@student.1337.ma> +#+ +:+ +#+ */
7
7
/* +#+#+#+#+#+ +#+ */
8
8
/* 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 */
10
10
/* */
11
11
/* ************************************************************************** */
12
12
13
- #include "libftprintf .h"
13
+ #include "ft_printf .h"
14
14
15
15
int conversions (char spiecifier , va_list args )
16
16
{
@@ -33,5 +33,7 @@ int conversions(char spiecifier, va_list args)
33
33
count += ft_putunsigned (va_arg (args , unsigned ));
34
34
else if (spiecifier == '%' )
35
35
count += ft_putchar ('%' );
36
+ else
37
+ return (-1 );
36
38
return (count );
37
39
}
Original file line number Diff line number Diff line change 3
3
/* ::: :::::::: */
4
4
/* ft_printf.c :+: :+: :+: */
5
5
/* +:+ +:+ +:+ */
6
- /* By: mel-mouh <mel-mouh@student.42.fr> +#+ +:+ +#+ */
6
+ /* By: mel-mouh <mel-mouh@student.1337.ma> +#+ +:+ +#+ */
7
7
/* +#+#+#+#+#+ +#+ */
8
8
/* 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 */
10
10
/* */
11
11
/* ************************************************************************** */
12
12
13
- #include "libftprintf .h"
13
+ #include "ft_printf .h"
14
14
15
15
int ft_printf (const char * str , ...)
16
16
{
17
17
int i ;
18
18
int count ;
19
19
va_list args ;
20
20
21
+ if (str == NULL )
22
+ return (-1 );
21
23
va_start (args , str );
22
24
i = 0 ;
23
25
count = 0 ;
Original file line number Diff line number Diff line change 1
1
/* ************************************************************************** */
2
2
/* */
3
3
/* ::: :::::::: */
4
- /* libftprintf .h :+: :+: :+: */
4
+ /* ft_printf .h :+: :+: :+: */
5
5
/* +:+ +:+ +:+ */
6
- /* By: mel-mouh <mel-mouh@student.42.fr> +#+ +:+ +#+ */
6
+ /* By: mel-mouh <mel-mouh@student.1337.ma> +#+ +:+ +#+ */
7
7
/* +#+#+#+#+#+ +#+ */
8
8
/* 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 */
10
10
/* */
11
11
/* ************************************************************************** */
12
12
13
- #ifndef LIBFTPRINTF_H
14
- # define LIBFTPRINTF_H
13
+ #ifndef FT_PRINTF_H
14
+ # define FT_PRINTF_H
15
15
16
16
# include <stdio.h>
17
17
# include <unistd.h>
Original file line number Diff line number Diff line change 3
3
/* ::: :::::::: */
4
4
/* ft_putaddres.c :+: :+: :+: */
5
5
/* +:+ +:+ +:+ */
6
- /* By: mel-mouh <mel-mouh@student.42.fr> +#+ +:+ +#+ */
6
+ /* By: mel-mouh <mel-mouh@student.1337.ma> +#+ +:+ +#+ */
7
7
/* +#+#+#+#+#+ +#+ */
8
8
/* 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 */
10
10
/* */
11
11
/* ************************************************************************** */
12
12
13
- #include "libftprintf .h"
13
+ #include "ft_printf .h"
14
14
15
15
int ft_putaddres (unsigned long int addr )
16
16
{
Original file line number Diff line number Diff line change 3
3
/* ::: :::::::: */
4
4
/* ft_putchar.c :+: :+: :+: */
5
5
/* +:+ +:+ +:+ */
6
- /* By: mel-mouh <mel-mouh@student.42.fr> +#+ +:+ +#+ */
6
+ /* By: mel-mouh <mel-mouh@student.1337.ma> +#+ +:+ +#+ */
7
7
/* +#+#+#+#+#+ +#+ */
8
8
/* 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 */
10
10
/* */
11
11
/* ************************************************************************** */
12
12
13
- #include "libftprintf .h"
13
+ #include "ft_printf .h"
14
14
15
15
int ft_putchar (char c )
16
16
{
Original file line number Diff line number Diff line change 3
3
/* ::: :::::::: */
4
4
/* ft_putnbr.c :+: :+: :+: */
5
5
/* +:+ +:+ +:+ */
6
- /* By: mel-mouh <mel-mouh@student.42.fr> +#+ +:+ +#+ */
6
+ /* By: mel-mouh <mel-mouh@student.1337.ma> +#+ +:+ +#+ */
7
7
/* +#+#+#+#+#+ +#+ */
8
8
/* 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 */
10
10
/* */
11
11
/* ************************************************************************** */
12
12
13
- #include "libftprintf .h"
13
+ #include "ft_printf .h"
14
14
15
15
static int leen (int n )
16
16
{
Original file line number Diff line number Diff line change 3
3
/* ::: :::::::: */
4
4
/* ft_putnbrhex.c :+: :+: :+: */
5
5
/* +:+ +:+ +:+ */
6
- /* By: mel-mouh <mel-mouh@student.42.fr> +#+ +:+ +#+ */
6
+ /* By: mel-mouh <mel-mouh@student.1337.ma> +#+ +:+ +#+ */
7
7
/* +#+#+#+#+#+ +#+ */
8
8
/* 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 */
10
10
/* */
11
11
/* ************************************************************************** */
12
12
13
- #include "libftprintf .h"
13
+ #include "ft_printf .h"
14
14
15
15
int ft_putnbr_hex (unsigned long int n , char * hexa )
16
16
{
@@ -27,7 +27,7 @@ int ft_putnbr_hex(unsigned long int n, char *hexa)
27
27
n /= 16 ;
28
28
}
29
29
count = i ;
30
- while (i >= 0 )
30
+ while (i > 0 )
31
31
ft_putchar (buffer [-- i ]);
32
32
return (count );
33
33
}
Original file line number Diff line number Diff line change 3
3
/* ::: :::::::: */
4
4
/* ft_putstr.c :+: :+: :+: */
5
5
/* +:+ +:+ +:+ */
6
- /* By: mel-mouh <mel-mouh@student.42.fr> +#+ +:+ +#+ */
6
+ /* By: mel-mouh <mel-mouh@student.1337.ma> +#+ +:+ +#+ */
7
7
/* +#+#+#+#+#+ +#+ */
8
8
/* 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 */
10
10
/* */
11
11
/* ************************************************************************** */
12
12
13
- #include "libftprintf .h"
13
+ #include "ft_printf .h"
14
14
15
15
int ft_putstr (char * s )
16
16
{
17
17
size_t i ;
18
18
19
19
i = 0 ;
20
20
if (s == NULL )
21
- return (-1 );
21
+ return (ft_putstr ( "(null)" ) );
22
22
while (s [i ] != '\0' )
23
23
{
24
24
write (1 , & s [i ], 1 );
Original file line number Diff line number Diff line change 3
3
/* ::: :::::::: */
4
4
/* ft_putunsigned.c :+: :+: :+: */
5
5
/* +:+ +:+ +:+ */
6
- /* By: mel-mouh <mel-mouh@student.42.fr> +#+ +:+ +#+ */
6
+ /* By: mel-mouh <mel-mouh@student.1337.ma> +#+ +:+ +#+ */
7
7
/* +#+#+#+#+#+ +#+ */
8
8
/* 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 */
10
10
/* */
11
11
/* ************************************************************************** */
12
12
13
- #include "libftprintf .h"
13
+ #include "ft_printf .h"
14
14
15
15
static int leen (unsigned int n )
16
16
{
@@ -30,6 +30,8 @@ int ft_putunsigned(unsigned int n)
30
30
int i ;
31
31
32
32
i = leen (n );
33
+ if (n == 0 )
34
+ i += 1 ;
33
35
if (n > 9 )
34
36
{
35
37
ft_putunsigned (n / 10 );
You can’t perform that action at this time.
0 commit comments