-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_showstr.c
53 lines (48 loc) · 851 Bytes
/
my_showstr.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
** my_showstr.c for in /u/epitech_2012/brenne_t/cu/rendu/piscine/1
**
** Made by thomas brennetot
** Login <[email protected]>
**
** Started on Fri Oct 12 15:55:15 2007 thomas brennetot
** Last update Mon Oct 15 20:18:59 2007 thomas brennetot
*/
#include "my.h"
int my_putnbr_base_2(int n, char *base)
{
int len;
len = my_strlen(base);
if (n < 0)
{
my_putchar('-');
my_putnbr_base_2(-n, base);
}
else
{
if (n < len)
my_putchar(n + '0');
else
{
my_putnbr_base_2(n / len, base);
my_putchar(base[n % len]);
}
}
return (0);
}
int my_showstr(char *str)
{
int i;
i = 0;
while (str[i] != '\0')
{
if ((str[i] >= 32) && (str[i] < 127))
my_putchar(str[i]);
else
{
my_putchar('\\');
my_putnbr_base_2(str[i], "0123467");
}
i++;
}
return (0);
}