-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_width.c
More file actions
36 lines (32 loc) · 597 Bytes
/
get_width.c
File metadata and controls
36 lines (32 loc) · 597 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
#include "main.h"
/**
* get_width - wih to be printed
* @format: string to print
* @i: bunch of arguments to be printed
* @list: args variadic
*
* Return: width.
*/
int get_width(const char *format, int *i, va_list list)
{
int widthh = 0;
int current_i;
for (current_i = *i + 1; format[current_i] != '\0'; current_i++)
{
if (is_digit(format[current_i]))
{
widthh *= 10;
widthh += format[current_i] - '0';
}
else if (format[current_i] == '*')
{
current_i++;
widthh = va_arg(list, int);
break;
}
else
break;
}
*i = current_i - 1;
return (widthh);
}