-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
012 [Fixed] hex format repaired working properly.
- Loading branch information
Showing
4 changed files
with
18 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
# By: salecler <[email protected]> +#+ +:+ +#+ # | ||
# +#+#+#+#+#+ +#+ # | ||
# Created: 2022/08/24 16:23:21 by salecler #+# #+# # | ||
# Updated: 2022/08/24 17:35:57 by salecler ### ########.fr # | ||
# Updated: 2022/08/25 11:30:49 by salecler ### ########.fr # | ||
# # | ||
# **************************************************************************** # | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: salecler <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/08/24 11:56:09 by salecler #+# #+# */ | ||
/* Updated: 2022/08/24 17:54:35 by salecler ### ########.fr */ | ||
/* Updated: 2022/08/25 11:28:54 by salecler ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -27,6 +27,6 @@ int ft_putstr(char *str); | |
//Formats archive | ||
int ft_putnbr(int n); | ||
int ft_putnbr_base(unsigned long n, char *base); | ||
int ft_puthex(int n, char *base); | ||
int ft_puthex(size_t n, char *base); | ||
int ft_putptr(void *n); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: salecler <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/08/24 11:55:55 by salecler #+# #+# */ | ||
/* Updated: 2022/08/24 17:47:05 by salecler ### ########.fr */ | ||
/* Updated: 2022/08/25 11:29:38 by salecler ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -43,7 +43,7 @@ int ft_putnbr_base(unsigned long n, char *base) | |
|
||
nbr = (unsigned int)n; | ||
len = 0; | ||
if (nbr > 16) | ||
if (nbr >= 16) | ||
{ | ||
ft_putnbr_base(nbr / 16, base); | ||
nbr = nbr % 16; | ||
|
@@ -53,41 +53,32 @@ int ft_putnbr_base(unsigned long n, char *base) | |
return (len); | ||
} | ||
|
||
int ft_puthex(int n, char *base) | ||
int ft_puthex(size_t n, char *base) | ||
{ | ||
int len; | ||
int nbr; | ||
static int len; | ||
|
||
len = 0; | ||
nbr = n; | ||
if (nbr < 0) | ||
if (n >= 16) | ||
{ | ||
write(1, "-", 1); | ||
nbr *= -1; | ||
} | ||
if (nbr > 16) | ||
{ | ||
ft_puthex(nbr / 16, base); | ||
nbr = nbr % 16; | ||
ft_puthex(n / 16, base); | ||
n = n % 16; | ||
} | ||
len++; | ||
ft_putchar(nbr + '0'); | ||
if (n < 0) | ||
len++; | ||
ft_putchar(base[n]); | ||
return (len); | ||
} | ||
|
||
int ft_putptr(void *n) | ||
{ | ||
int len; | ||
int nbr; | ||
char *base; | ||
int len; | ||
size_t nbr; | ||
char *base; | ||
|
||
len = 0; | ||
nbr = (int)n; | ||
nbr = (size_t)n; | ||
base = "0123456789abcdef"; | ||
write(1, "0x", 2); | ||
len += 2; | ||
len += ft_putnbr_base(nbr, base); | ||
len += ft_puthex(nbr, base); | ||
return (len); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,12 @@ | |
/* By: salecler <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2022/08/22 18:32:02 by salecler #+# #+# */ | ||
/* Updated: 2022/08/24 17:48:56 by salecler ### ########.fr */ | ||
/* Updated: 2022/08/25 11:31:23 by salecler ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "../include/ft_printf.h" | ||
#include <stdio.h> | ||
|
||
int ft_printf(const char *str, ...) | ||
{ | ||
|