diff options
Diffstat (limited to 'src/str')
| -rw-r--r-- | src/str/ft_atoi.c | 7 | ||||
| -rw-r--r-- | src/str/ft_strsjoin.c | 12 | ||||
| -rw-r--r-- | src/str/ft_strsjoinf.c | 9 |
3 files changed, 23 insertions, 5 deletions
diff --git a/src/str/ft_atoi.c b/src/str/ft_atoi.c index d6fa5bb..b8f979d 100644 --- a/src/str/ft_atoi.c +++ b/src/str/ft_atoi.c @@ -6,14 +6,17 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/10/07 09:46:16 by cacharle #+# #+# */ -/* Updated: 2020/01/15 10:56:06 by cacharle ### ########.fr */ +/* Updated: 2020/04/04 22:34:33 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" /* -** Convert a string to an int +** \brief Extract first int in a string +** (takes as much digits has possible) +** \param str String to convert +** \return Extracted int */ int ft_atoi(const char *str) diff --git a/src/str/ft_strsjoin.c b/src/str/ft_strsjoin.c index 507903b..0923bde 100644 --- a/src/str/ft_strsjoin.c +++ b/src/str/ft_strsjoin.c @@ -6,12 +6,20 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/04 14:30:08 by charles #+# #+# */ -/* Updated: 2020/04/04 14:45:58 by charles ### ########.fr */ +/* Updated: 2020/04/04 23:34:30 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft_str.h" +/* +** \brief Join null-terminated array of strings +** \param strs Array of strings +** \param delim String iterspersed between strings +** \return Joined string or NULL on error +** \note Empty strings are ignored +*/ + char *ft_strsjoin(char **strs, char *delim) { int i; @@ -35,7 +43,7 @@ char *ft_strsjoin(char **strs, char *delim) while (strs[++i] != NULL) { ft_strcat(join, strs[i]); - if (strs[i + 1] != NULL) + if (*strs[i] != '\0' && strs[i + 1] != NULL) ft_strcat(join, delim); } return (join); diff --git a/src/str/ft_strsjoinf.c b/src/str/ft_strsjoinf.c index f5077c1..36a2892 100644 --- a/src/str/ft_strsjoinf.c +++ b/src/str/ft_strsjoinf.c @@ -6,12 +6,19 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/04 14:27:33 by charles #+# #+# */ -/* Updated: 2020/04/04 14:29:49 by charles ### ########.fr */ +/* Updated: 2020/04/04 23:24:24 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft_str.h" +/* +** \brief Join null-terminated array of strings and free the array +** \param strs Array of strings +** \param delim String which will be put between each string +** \return Joined string or NULL on error +*/ + char *ft_strsjoinf(char **strs, char *delim) { char *ret; |
