minishell
get_numstr_base.c File Reference
#include <stdbool.h>
#include <stddef.h>
#include "ft_string.h"
Include dependency graph for get_numstr_base.c:

Go to the source code of this file.

Functions

int get_numstr_base (char *buf, size_t num, int base, bool is_upper)
 

Function Documentation

◆ get_numstr_base()

int get_numstr_base ( char *  buf,
size_t  num,
int  base,
bool  is_upper 
)

Definition at line 17 of file get_numstr_base.c.

18 {
19  int tmp;
20  int last_len;
21  char c;
22 
23  if (num == 0)
24  return (0);
25  last_len = get_numstr_base(buf, num / base, base, is_upper);
26  tmp = num % base;
27  if (tmp < 10)
28  c = '0' + tmp;
29  else if (is_upper)
30  c = 'A' + tmp - 10;
31  else
32  c = 'a' + tmp - 10;
33  buf[last_len] = c;
34  return (last_len + 1);
35 }
int get_numstr_base(char *buf, size_t num, int base, bool is_upper)
Here is the call graph for this function:
Here is the caller graph for this function: