-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_flags.c
More file actions
30 lines (28 loc) · 654 Bytes
/
Copy pathget_flags.c
File metadata and controls
30 lines (28 loc) · 654 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
#include "main.h"
/**
* get_flags - Gets all the flags
* @format: Strung to print args
* @i: parameter parsed
* Return: all flags
*/
int get_flags(const char *format, int *i)
{
int k, current_i;
int flags = 0;
const char FLAG_CHARACTER[] = {'+', '-', '0', ' ', '#', '\0'};
const int FLAG_ARRAYS[] = {F_PLUS, F_MINUS, F_ZERO, F_SPACE, F_HASH,
0};
for (current_i = *i + 1; format[current_i] != '\0'; current_i++)
{
for (k = 0; FLAG_CHARACTER[k] != '\0'; k++)
if (format[current_i] == FLAG_CHARACTER[k])
{
flags |= FLAG_ARRAYS[k];
break;
}
if (FLAG_CHARACTER[k] == 0)
break;
}
*i = current_i - 1;
return (flags);
}