-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlength_modifiers.c
More file actions
73 lines (66 loc) · 1.14 KB
/
Copy pathlength_modifiers.c
File metadata and controls
73 lines (66 loc) · 1.14 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "main.h"
/**
* handle_long - function handles 'long' length modifier.
*
* @data:
* @args:
*/
void handle_long(arg_data_t *data, va_list args)
{
long arg = va_arg(args, long);
}
/**
* handle_short - function handles 'short' length modifier.
*
* @data:
* @args:
*/
void handle_short(arg_data_t *data, va_list args)
{
short arg = (short)va_arg(args, int);
}
/**
* init_length_modifiers -
*/
length_modifier_t *init_length_modifiers(void)
{
static length_modifier_t length_modifiers[] = {
{"l", handle_long},
{"h", handle_short},
{NULL, NULL}
};
return (length_modifiers);
}
/**
* _strlen - function returns the length of a string.
*
* @s: pointer to a string to return length of.
*
* Return: the length of the string.
*/
int _strlen(const char *s)
{
int len = 0;
while (s[len] != '\0')
{
len++;
}
return (len);
}
/**
* _strcmp - function compares two strings.
*
* @s1: pointer to the first string.
* @s2: pointer to the second string.
*
* Return:
*/
int _strcmp(const char *s1, const char *s2)
{
while (*s1 && (*s1 == *s2))
{
s1++;
s2++;
}
return (*(const unsigned char *)s1 - *(const unsigned char *)s2);
}