maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
ft_is_double.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* ft_is_double.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: rmikhayl <marvin@42.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2024/05/15 14:50:05 by rmikhayl #+# #+# */
9/* Updated: 2024/05/15 14:50:06 by rmikhayl ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "libft.h"
14
15int ft_is_double(const char *n)
16{
17 unsigned long i;
18 int p;
19
20 i = 0;
21 while (n[i] && (n[i] == '\t' || n[i] == '\n' || n[i] == '\v'
22 || n[i] == '\f' || n[i] == '\r' || n[i] == ' '))
23 i++;
24 if (n[i] && (n[i] == '+' || n[i] == '-'))
25 i++;
26 if (!n[i])
27 return (FALSE);
28 p = FALSE;
29 while (n[i])
30 {
31 if (!ft_isdigit(n[i]) && n[i] != '.' && n[i] != ',')
32 return (FALSE);
33 if ((n[i] == '.' || n[i] == ',') && p == TRUE)
34 return (FALSE);
35 if (n[i] == '.' || n[i] == ',')
36 p = TRUE;
37 i++;
38 }
39 return (TRUE);
40}
int ft_is_double(const char *n)
int ft_isdigit(int c)
Definition ft_isdigit.c:13
#define TRUE
Definition libft.h:104
#define FALSE
Definition libft.h:105