-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflag.c
56 lines (46 loc) · 950 Bytes
/
flag.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
#include "main.h"
/**
* flag_plus - checks all flag + available
*
* @str: pointer to string
*
* Return: 1 if true else 0
*/
int flag_plus(const char **str)
{
int i = 0;
for (; (**str == '+') || (**str == '#') || (**str == ' '); (*str)++)
(**str == '+') ? (i = 1) : (i += 0);
return (i);
}
/**
* flag_hash - checks all flag # available
*
* @str: pointer to string
*
* Return: 1 if true else 0
*/
int flag_hash(const char **str)
{
int i = 0;
for (; (**str == '+') || (**str == '#') || (**str == ' '); (*str)++)
(**str == '#') ? (i = 1) : (i += 0);
return (i);
}
/**
* flag_space - checks all empty space available
*
* @s: pointer to string
* @val: value of variable list
*
* Return: 1 if true else 0
*/
int flag_space(const char **s, long int val)
{
int i = 0;
for (; (**s == ' ') || (**s == '#'); (*s)++)
i = 1;
if (val < 0 || (**s != 'i' && **s != 'l' && **s != 'd' && **s != 'h'))
i = 0;
return (i);
}