-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_isnum.c
More file actions
41 lines (38 loc) · 1.25 KB
/
Copy pathft_isnum.c
File metadata and controls
41 lines (38 loc) · 1.25 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isnum.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mmasarov <mmasarov@student.42vienna.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/03 14:12:39 by mmasarov #+# #+# */
/* Updated: 2024/10/03 14:12:41 by mmasarov ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isnum(char *str)
{
int has_digit;
has_digit = 0;
while (ft_isspace(*str))
str++;
if (*str == '+' || *str == '-')
str++;
while (ft_isdigit(*str))
{
has_digit = 1;
str++;
}
if (*str == '.')
{
str++;
while (ft_isdigit(*str))
{
has_digit = 1;
str++;
}
}
while (ft_isspace(*str))
str++;
return (*str == '\0' && has_digit);
}