-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers2.c
More file actions
48 lines (44 loc) · 775 Bytes
/
helpers2.c
File metadata and controls
48 lines (44 loc) · 775 Bytes
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
#include "main.h"
/**
* is_whitespace - checks if a string consists of only whitespace
* @str: input string to check
*
* Return: status
*/
int is_whitespace(const char *str)
{
while (*str != '\0')
{
if (!_isspace(*str))
return (0);
str++;
}
return (1);
}
/**
* _isspace - checks if character is a space character
* @c: char to check
*
* Return: status
*/
int _isspace(int c)
{
return (c == ' ' || c == '\t' || c == '\r' || c == '\f' ||
c == '\v' || c == '\a' || c == '\n');
}
/**
* _isdigit - defines if string passed is a number
*
* @s: input string
* Return: 1 if string is a number. 0 in other case.
*/
int _isdigit(const char *s)
{
unsigned int i;
for (i = 0; s[i]; i++)
{
if (s[i] < 48 || s[i] > 57)
return (0);
}
return (1);
}