-
Notifications
You must be signed in to change notification settings - Fork 0
/
tools.c
59 lines (52 loc) · 835 Bytes
/
tools.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
54
55
56
57
58
/*
** tools.c for in /u/epitech_2012/brenne_t/cu/rendu/c/my_printf
**
** Made by thomas brennetot
** Login <[email protected]>
**
** Started on Sun Dec 23 18:43:39 2007 thomas brennetot
** Last update Tue Dec 25 19:01:46 2007 thomas brennetot
*/
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include "my_printf.h"
void my_putchar(char c)
{
write(1, &c, 1);
}
int my_strlen(char *str)
{
int i;
i = 0;
while (str[i] != '\0')
i++;
return (i);
}
void my_put_nbr(int nb)
{
if (nb < 0)
{
my_putchar('-');
my_put_nbr(-nb);
}
else
{
if (nb < 10)
my_putchar(nb + '0');
else
{
my_put_nbr(nb/10);
my_putchar((nb%10) + '0');
}
}
return;
}
void my_putstr(char *str)
{
while (*str != '\0')
{
write(1, str, 1);
str++;
}
}