libft reformat
This commit is contained in:
37
str/ft_atoi.c
Normal file
37
str/ft_atoi.c
Normal file
@ -0,0 +1,37 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_atoi.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/10/31 09:00:27 by adjoly #+# #+# */
|
||||
/* Updated: 2023/11/05 15:27:36 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_atoi(const char *nptr)
|
||||
{
|
||||
int i;
|
||||
int sign;
|
||||
int nbr;
|
||||
|
||||
i = 0;
|
||||
sign = 1;
|
||||
nbr = 0;
|
||||
while ((nptr[i] >= 7 && nptr[i] <= 13) || nptr[i] == 32)
|
||||
i++;
|
||||
if (nptr[i] == '-')
|
||||
{
|
||||
sign *= -1;
|
||||
i++;
|
||||
}
|
||||
else if (nptr[i] == '+')
|
||||
i++;
|
||||
while (nptr[i] >= '0' && nptr[i] <= '9')
|
||||
{
|
||||
nbr = nbr * 10 + (nptr[i] - '0');
|
||||
i++;
|
||||
}
|
||||
return (nbr * sign);
|
||||
}
|
58
str/ft_itoa.c
Normal file
58
str/ft_itoa.c
Normal file
@ -0,0 +1,58 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_itoa.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/05 16:26:26 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/04 14:45:39 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../libft.h"
|
||||
|
||||
static int ft_count_digit(int n)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
if (n < 0)
|
||||
i++;
|
||||
if (n == 0)
|
||||
return (1);
|
||||
while (n)
|
||||
{
|
||||
n /= 10;
|
||||
i++;
|
||||
}
|
||||
return (i);
|
||||
}
|
||||
|
||||
char *ft_itoa(int n)
|
||||
{
|
||||
char *result;
|
||||
int i;
|
||||
|
||||
i = ft_count_digit(n);
|
||||
if (n == 0)
|
||||
return (ft_strdup("0"));
|
||||
if (n == -2147483648)
|
||||
return (ft_strdup("-2147483648"));
|
||||
result = malloc(sizeof(char) * (i + 1));
|
||||
if (result == NULL)
|
||||
return (NULL);
|
||||
result[i--] = '\0';
|
||||
if (n < 0)
|
||||
{
|
||||
result[0] = '-';
|
||||
n = -n;
|
||||
}
|
||||
while (n)
|
||||
{
|
||||
result[i] = n % 10 + '0';
|
||||
n /= 10;
|
||||
i--;
|
||||
}
|
||||
return (result);
|
||||
}
|
94
str/ft_split.c
Normal file
94
str/ft_split.c
Normal file
@ -0,0 +1,94 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_split.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/12 09:14:19 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/04 14:43:50 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../libft.h"
|
||||
|
||||
static int ft_countword(char const *s, char sep)
|
||||
{
|
||||
int i;
|
||||
int w_count;
|
||||
|
||||
i = 0;
|
||||
w_count = 0;
|
||||
while (s[i])
|
||||
{
|
||||
if (s[i] != sep && (i == 0 || s[i - 1] == sep))
|
||||
w_count++;
|
||||
i++;
|
||||
}
|
||||
return (w_count);
|
||||
}
|
||||
|
||||
static int ft_countletter(char const *s, char sep)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (s[i] != sep && s[i] != '\0')
|
||||
i++;
|
||||
return (i);
|
||||
}
|
||||
|
||||
static void *ft_freearr(char **arr)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (arr[i])
|
||||
{
|
||||
free(arr[i]);
|
||||
i++;
|
||||
}
|
||||
free(arr);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
char **ft_split_to_result(char **tab, char const *s, char c)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (s[i])
|
||||
{
|
||||
if (s[i] != c)
|
||||
{
|
||||
k = 0;
|
||||
tab[j] = ft_calloc(ft_countletter(&s[i], c) + 1, sizeof(char));
|
||||
if (!tab[j])
|
||||
return (ft_freearr(tab));
|
||||
while (s[i] && s[i] != c)
|
||||
tab[j][k++] = s [i++];
|
||||
tab[j][k] = '\0';
|
||||
j++;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
}
|
||||
tab[j] = NULL;
|
||||
return (tab);
|
||||
}
|
||||
|
||||
char **ft_split(char const *s, char c)
|
||||
{
|
||||
char **result;
|
||||
|
||||
if (s == NULL)
|
||||
return (NULL);
|
||||
result = ft_calloc(ft_countword(s, c) + 1, sizeof(char *));
|
||||
if (!result)
|
||||
return (NULL);
|
||||
result = ft_split_to_result(result, s, c);
|
||||
return (result);
|
||||
}
|
25
str/ft_strchr.c
Normal file
25
str/ft_strchr.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strchr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/01 15:45:18 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/04 14:44:11 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../libft.h"
|
||||
|
||||
char *ft_strchr(const char *s, int c)
|
||||
{
|
||||
size_t len_s;
|
||||
char *result;
|
||||
|
||||
len_s = ft_strlen(s);
|
||||
result = ft_memchr(s, c, len_s);
|
||||
if (c == 0)
|
||||
return ((char *)s + len_s);
|
||||
return (result);
|
||||
}
|
33
str/ft_strdup.c
Normal file
33
str/ft_strdup.c
Normal file
@ -0,0 +1,33 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strdup.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/03 22:57:39 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/04 14:44:58 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../libft.h"
|
||||
|
||||
char *ft_strdup(const char *s)
|
||||
{
|
||||
int i;
|
||||
char *result;
|
||||
int len;
|
||||
|
||||
i = 0;
|
||||
len = ft_strlen(s);
|
||||
result = malloc(sizeof(char) * (len + 1));
|
||||
if (result == NULL)
|
||||
return (NULL);
|
||||
while (s[i])
|
||||
{
|
||||
result[i] = s[i];
|
||||
i++;
|
||||
}
|
||||
result[i] = '\0';
|
||||
return (result);
|
||||
}
|
27
str/ft_striteri.c
Normal file
27
str/ft_striteri.c
Normal file
@ -0,0 +1,27 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_striteri.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/11 14:15:30 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/04 14:45:11 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../libft.h"
|
||||
|
||||
void ft_striteri(char *s, void (*f)(unsigned int, char *))
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
if (s == NULL || f == NULL)
|
||||
return ;
|
||||
while (s[i])
|
||||
{
|
||||
f(i, &s[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
41
str/ft_strjoin.c
Normal file
41
str/ft_strjoin.c
Normal file
@ -0,0 +1,41 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strjoin.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/04 13:44:09 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/04 14:45:30 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../libft.h"
|
||||
|
||||
char *ft_strjoin(char const *s1, char const *s2)
|
||||
{
|
||||
char *result;
|
||||
size_t i;
|
||||
size_t j;
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
if (s1 == NULL || s2 == NULL)
|
||||
return (NULL);
|
||||
result = ft_calloc((ft_strlen(s1) + ft_strlen(s2) + 1), sizeof(char));
|
||||
if (result == NULL)
|
||||
return (NULL);
|
||||
while (s1[i])
|
||||
{
|
||||
result[i] = s1[i];
|
||||
i++;
|
||||
}
|
||||
while (s2[j])
|
||||
{
|
||||
result[i] = s2[j];
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
result[i] = '\0';
|
||||
return (result);
|
||||
}
|
38
str/ft_strlcat.c
Normal file
38
str/ft_strlcat.c
Normal file
@ -0,0 +1,38 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlcat.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/03 15:59:31 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/04 14:47:03 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../libft.h"
|
||||
|
||||
size_t ft_strlcat(char *dst, const char *src, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
size_t j;
|
||||
size_t len_dst;
|
||||
size_t len_src;
|
||||
|
||||
if (dst == NULL && size == 0)
|
||||
return (0);
|
||||
i = 0;
|
||||
j = ft_strlen(dst);
|
||||
len_src = ft_strlen(src);
|
||||
len_dst = ft_strlen(dst);
|
||||
if (size <= j)
|
||||
return (len_src + size);
|
||||
while (j < size - 1 && src[i])
|
||||
{
|
||||
dst[j] = src[i];
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
dst[j] = '\0';
|
||||
return (len_src + len_dst);
|
||||
}
|
30
str/ft_strlcpy.c
Normal file
30
str/ft_strlcpy.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlcpy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/01 09:52:45 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/04 14:47:41 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../libft.h"
|
||||
|
||||
size_t ft_strlcpy(char *dst, const char *src, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
if (size == 0)
|
||||
return (ft_strlen(src));
|
||||
while (i < size - 1 && src[i])
|
||||
{
|
||||
dst[i] = src[i];
|
||||
i++;
|
||||
}
|
||||
if (i < size)
|
||||
dst[i] = '\0';
|
||||
return (ft_strlen(src));
|
||||
}
|
26
str/ft_strlen.c
Normal file
26
str/ft_strlen.c
Normal file
@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlen.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/10/30 18:15:57 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/04 15:10:15 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../libft.h"
|
||||
|
||||
size_t ft_strlen(const char *s)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
while (*s)
|
||||
{
|
||||
s++;
|
||||
i++;
|
||||
}
|
||||
return (i);
|
||||
}
|
33
str/ft_strmapi.c
Normal file
33
str/ft_strmapi.c
Normal file
@ -0,0 +1,33 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strmapi.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/11 11:44:24 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/04 14:48:02 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../libft.h"
|
||||
|
||||
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
|
||||
{
|
||||
int i;
|
||||
char *res;
|
||||
|
||||
i = 0;
|
||||
if (!s || !f)
|
||||
return (NULL);
|
||||
res = ft_calloc((ft_strlen(s) + 1), sizeof(char));
|
||||
if (res == NULL)
|
||||
return (NULL);
|
||||
while (s[i])
|
||||
{
|
||||
res[i] = f(i, s[i]);
|
||||
i++;
|
||||
}
|
||||
res[i] = '\0';
|
||||
return (res);
|
||||
}
|
25
str/ft_strncmp.c
Normal file
25
str/ft_strncmp.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strncmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/05 10:40:45 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/04 14:48:12 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../libft.h"
|
||||
|
||||
int ft_strncmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
if (n == 0)
|
||||
return (0);
|
||||
while (s1[i] == s2[i] && s1[i] && i < n - 1)
|
||||
i++;
|
||||
return ((unsigned char)s1[i] - (unsigned char)s2[i]);
|
||||
}
|
35
str/ft_strnstr.c
Normal file
35
str/ft_strnstr.c
Normal file
@ -0,0 +1,35 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strnstr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/08 16:02:17 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/04 14:48:22 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../libft.h"
|
||||
|
||||
char *ft_strnstr(const char *big, const char *little, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
size_t j;
|
||||
|
||||
i = 0;
|
||||
if (!big && len == 0)
|
||||
return (NULL);
|
||||
if (*little == '\0' || little == big)
|
||||
return ((char *)big);
|
||||
while (i < len && big[i])
|
||||
{
|
||||
j = 0;
|
||||
while (big[i + j] == little[j] && little[j] && big[i] && i + j < len)
|
||||
j++;
|
||||
if (little[j] == 0)
|
||||
return ((char *)big + i);
|
||||
i++;
|
||||
}
|
||||
return (NULL);
|
||||
}
|
33
str/ft_strrchr.c
Normal file
33
str/ft_strrchr.c
Normal file
@ -0,0 +1,33 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strrchr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/08 14:44:26 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/04 14:48:34 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../libft.h"
|
||||
|
||||
char *ft_strrchr(const char *s, int c)
|
||||
{
|
||||
size_t i;
|
||||
size_t len_s;
|
||||
|
||||
len_s = ft_strlen(s);
|
||||
i = len_s;
|
||||
if (c == 0)
|
||||
return (&((char *)s)[len_s]);
|
||||
while (i > 0)
|
||||
{
|
||||
if (s[i] == (char)c)
|
||||
return (&((char *)s)[i]);
|
||||
i--;
|
||||
}
|
||||
if (s[0] == (char)c)
|
||||
return (&((char *)s)[0]);
|
||||
return (NULL);
|
||||
}
|
31
str/ft_strtrim.c
Normal file
31
str/ft_strtrim.c
Normal file
@ -0,0 +1,31 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strtrim.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/11 00:37:37 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/04 14:48:45 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../libft.h"
|
||||
|
||||
char *ft_strtrim(char const *s1, char const *set)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
char *result;
|
||||
|
||||
i = 0;
|
||||
if (s1 == NULL || set == NULL)
|
||||
return (NULL);
|
||||
j = ft_strlen(s1);
|
||||
while (ft_strchr(set, s1[i]) != 0)
|
||||
i++;
|
||||
while (ft_strrchr(set, s1[j]) != 0)
|
||||
j--;
|
||||
result = ft_substr(s1, i, (j - i) + 1);
|
||||
return (result);
|
||||
}
|
37
str/ft_substr.c
Normal file
37
str/ft_substr.c
Normal file
@ -0,0 +1,37 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_substr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/02 17:59:58 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/04 14:48:54 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../libft.h"
|
||||
|
||||
char *ft_substr(char const *s, unsigned int start, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
char *result;
|
||||
|
||||
i = 0;
|
||||
if (s == NULL)
|
||||
return (0);
|
||||
if (len >= ft_strlen(s))
|
||||
len = ft_strlen(s) - start;
|
||||
if (len == 0 || start >= ft_strlen(s))
|
||||
return (ft_calloc(1, 1));
|
||||
result = malloc((len + 1) * sizeof(char));
|
||||
if (result == NULL)
|
||||
return (NULL);
|
||||
while (i < len && s[start + i])
|
||||
{
|
||||
result[i] = s[start + i];
|
||||
i++;
|
||||
}
|
||||
result[i] = '\0';
|
||||
return (result);
|
||||
}
|
18
str/ft_tolower.c
Normal file
18
str/ft_tolower.c
Normal file
@ -0,0 +1,18 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_tolower.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/10/31 17:15:28 by adjoly #+# #+# */
|
||||
/* Updated: 2023/10/31 17:26:10 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_tolower(int c)
|
||||
{
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
return (c + 32);
|
||||
return (c);
|
||||
}
|
18
str/ft_toupper.c
Normal file
18
str/ft_toupper.c
Normal file
@ -0,0 +1,18 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_toupper.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/10/31 17:15:28 by adjoly #+# #+# */
|
||||
/* Updated: 2023/10/31 17:26:15 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_toupper(int c)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
return (c - 32);
|
||||
return (c);
|
||||
}
|
Reference in New Issue
Block a user