-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunc_nbr.c
58 lines (51 loc) · 956 Bytes
/
func_nbr.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
/*
** func_nbr.c for Projet-Bistro in /home/giallo_n/git/Projet-Bistro
**
** Made by nathan giallombardo
** Login <giallo_n@epitech.net>
**
** Started on Tue Oct 29 12:56:58 2013 nathan giallombardo
** Last update Sun Nov 10 19:48:44 2013 nathan giallombardo
*/
#include <stdlib.h>
#include "my.h"
#include "bistromathique.h"
t_nb *make_nb(char *nbr)
{
int i;
int j;
int a;
i = 0;
a = 0;
if (nbr[i] == '-')
{
a = 1;
while (*nbr)
{
*nbr = (*nbr++);
}
my_putstr(nbr);
}
i = my_strlen(nbr);
return (make_nb_base(nbr, i, i - 1, a));
}
t_nb *make_nb_base(char *nbr, int size, int poss, int neg)
{
t_nb *nb;
nb = malloc(sizeof(t_nb));
nb->nbr = nbr;
nb->size = size;
nb->poss = poss;
nb->neg = neg;
return (nb);
}
t_nb *make_nb_empty(int size)
{
return (make_nb_base(xmalloc(size), size, 0, 0));
}
int print_nb(t_nb *nb)
{
if (nb->neg > 0)
my_putchar('-');
my_putstr(nb->nbr);
}