-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_utilstr.c
62 lines (55 loc) · 1.58 KB
/
ft_utilstr.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
57
58
59
60
61
62
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_utilstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lpalacio <lpalacio@student.42madrid> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/20 20:11:47 by lpalacio #+# #+# */
/* Updated: 2022/09/23 18:19:56 by lpalacio ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlcpy(char *dst, const char *src, size_t dstsize)
{
size_t i;
i = 0;
if (dstsize > 0)
{
while (src[i] != 0 && i < dstsize - 1)
{
dst[i] = src[i];
i++;
}
dst[i] = 0;
}
return (ft_strlen(src));
}
size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
{
size_t d;
size_t n;
d = ft_strlen(dst);
n = 0;
if (dstsize <= d)
return (dstsize + ft_strlen(src));
while ((d + n) < (dstsize - 1) && src[n] != 0)
{
dst[d + n] = src[n];
n++;
}
dst[d + n] = 0;
return (d + ft_strlen(src));
}
int ft_toupper(int c)
{
if (c >= 'a' && c <= 'z')
return (c - 32);
return (c);
}
int ft_tolower(int c)
{
if (c >= 'A' && c <= 'Z')
return (c + 32);
return (c);
}