File tree Expand file tree Collapse file tree 3 files changed +9
-9
lines changed
Expand file tree Collapse file tree 3 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 22#define MAIN_H
33#include <stdarg.h>
44#include <string.h>
5- #define ABS (x ) ((x) < 0 ? -(x) : (x))
65#define MIN (x , y ) (((x) < (y)) ? (x) : (y))
76#define MAX_BYTE_SIZE 30
87
@@ -14,7 +13,7 @@ void print_error(char *);
1413int parse_format (const char * );
1514
1615void * alloc (size_t );
17- char * int_to_string (int );
16+ char * int_to_string (long );
1817int str_write (char * );
1918int print_decimal (va_list );
2019
Original file line number Diff line number Diff line change @@ -18,17 +18,18 @@ int print_decimal(va_list ap)
1818{
1919 int count = 0 ;
2020 int num = va_arg (ap , int );
21+ long big_num = (long ) num ;
2122 char * number_string ;
2223
23- if (num < 0 )
24+ if (big_num < 0 )
2425 {
2526 write (1 , "-" , 1 );
2627 count ++ ;
27- num = ABS ( num );
28+ big_num = labs ( big_num );
2829 }
29- if (num == 0 )
30+ if (big_num == 0 )
3031 return (write (1 , "0" , 1 ));
31- number_string = int_to_string (num );
32+ number_string = int_to_string (big_num );
3233 count += str_write (number_string );
3334 free (number_string );
3435 va_end (ap );
Original file line number Diff line number Diff line change @@ -35,11 +35,11 @@ void *alloc(size_t size)
3535 * Return: (num_str) char *
3636 */
3737
38- char * int_to_string (int num )
38+ char * int_to_string (long num )
3939{
40- int length = 1 , tmp ;
40+ long length = 1 , tmp ;
4141 char * num_str ;
42- int i ;
42+ long i ;
4343
4444 tmp = num ;
4545
You can’t perform that action at this time.
0 commit comments