-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathis_double.c
40 lines (37 loc) · 1.26 KB
/
is_double.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* is_double.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hezzahir <hamza.ezzahiry@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/04 17:52:56 by hezzahir #+# #+# */
/* Updated: 2020/01/04 17:54:39 by hezzahir ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int is_double(char *word)
{
int i;
int nb_point;
i = 0;
nb_point = 0;
if (word[i] == '-' || word[i] == '+')
i++;
if (!ft_isdigit(word[i]))
return (0);
while (word[i])
{
if (ft_isdigit(word[i]) || word[i] == '.')
{
if (word[i] == '.')
nb_point++;
}
else
return (0);
i++;
}
if (word[i - 1] == '.' || nb_point > 1)
return (0);
return (1);
}