25#define INT_MAX_LENGTH 10
26#define PRECISION_FOR_FLOAT 8
47 for (
int i = 1; i <= a; ++i)
60 return (*c >=
'0' && *c <=
'9') ? 1 : 0;
113 char *buf = (
char *)
malloc(
sizeof(
char) + 1);
176 if (width > 0 && size < width)
177 for (
int i = 0; i < (width - precision); ++i)
180 if (precision > 0 && precision > size)
181 for (
int i = 0; i < (precision - size); ++i)
209 int reqd_blanks = width - (precision + 1) - ndigits;
218 dval = dval - (int) dval;
251 if (precision != 0 && precision < size)
255 for (
int i = 0; i < (width - size); ++i)
259 for (
int i = 0; i < size; ++i)
279 *width = *width * 10 + (*p++ -
'0');
284 *precision = *precision * 10 + (*p -
'0');
308 for (p = fmt; *p !=
'\0'; ++p) {
325 ival = va_arg(ap,
int);
329 cval = va_arg(ap,
int);
333 dval = va_arg(ap,
double);
337 precision = PRECISION_FOR_FLOAT;
341 sval = va_arg(ap,
char *);
#define malloc(bytes)
This macro replace the standard malloc function with malloc_dbg.
Definition: malloc_dbg.h:18
#define free(ptr)
This macro replace the standard free function with free_dbg.
Definition: malloc_dbg.h:26
void print_int_value(int n, int width, int precision)
Definition: min_printf.h:154
void min_printf(char *fmt,...)
min_printf is the function same as printf
Definition: min_printf.h:295
char get_ch(char *p, Buffer *buffer)
Returns specific required next character.
Definition: min_printf.h:70
void print_double_value(double dval, int width, int precision)
The algorithm here is also the same as the print_int_value function.
Definition: min_printf.h:206
int power_of_ten(int a)
Definition: min_printf.h:44
void reverse_str(char *p)
Reverses a string using two pointer algorithm
Definition: min_printf.h:124
char * get_width_and_precision(char *p, Buffer *buffer, int *width, int *precision)
Takes width and precision specified from the format of the string.
Definition: min_printf.h:271
void unget_ch(char *c, Buffer *buffer)
Stores character to the buffer->buffr_char
Definition: min_printf.h:84
#define INT_MAX_LENGTH
for malloc and free functions for write function for va_start and va_arg functions
Definition: min_printf.h:25
struct buffer Buffer
struct used to store character in certain times
void put_char(char s)
Prints one character on screen.
Definition: min_printf.h:110
int is_number(char *c)
Checks if a character is a number.
Definition: min_printf.h:58
int get_number_of_digits(int n)
Calculates the number of digits in a number.
Definition: min_printf.h:96
void print_string(char *p, int width, int precision)
Definition: min_printf.h:234
struct used to store character in certain times
Definition: min_printf.h:31