1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.

97 lines
1.9 KiB
C
Raw Normal View History

2023-08-06 20:12:38 +02:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_utils1.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lvincent <lvincent@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/30 17:50:34 by lvincent #+# #+# */
/* Updated: 2022/07/31 23:32:52 by lvincent ### ########.fr */
/* */
/* ************************************************************************** */
#include "rush02.h"
int ft_is_whitespace(char c)
{
if ((c >= 9 && c <= 13) || c == ' ')
return (1);
else
return (0);
}
int ft_strlen(char *str)
{
int i;
i = 0;
while (str[i] != '\0')
i++;
return (i);
}
char *ft_addchar(char *str, char c)
{
char *return_val;
int i;
i = 0;
while (str[i++])
;
return_val = malloc(i + 1);
i = 0;
return_val[0] = c;
while (str[i] != '\0')
{
return_val[i + 1] = str[i];
i++;
}
return_val[i + 1] = '\0';
free(str);
return (return_val);
}
char *ft_set_string_malloc(char *str)
{
char *r_value;
int i;
r_value = malloc(ft_strlen(str));
i = 0;
while (str[i])
{
r_value[i] = str[i];
i++;
}
r_value[i] = '\0';
return (r_value);
}
char **add_tab_str(char **tab, char *str)
{
char **tmp;
int i;
int size;
i = 0;
size = 0;
while (tab[i])
{
size += ft_strlen(tab[i]);
i++;
}
i = 0;
tmp = malloc(size);
while (tab[i])
{
tmp[i] = malloc(ft_strlen(tab[i]));
tmp[i] = tab[i];
i++;
}
tmp[i] = malloc(ft_strlen(tab[i]));
tmp[i] = str;
puts("yes");
free(tab);
return (tmp);
}