| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* ft_dup_first_word.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: bchanot <bchanot@student.42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2017/12/04 22:56:53 by bchanot #+# #+# */
- /* Updated: 2018/10/13 20:16:50 by bchanot ### ########.fr */
- /* */
- /* ************************************************************************** */
- #include "libft.h"
- char *ft_dup_first_word(const char *src)
- {
- const char *tmp;
- size_t i;
- char *ret;
- tmp = src;
- i = 0;
- while (*tmp && ((*tmp >= 7 && *tmp <= 13) || *tmp == ' '))
- tmp++;
- while (*tmp && ((*tmp < 7 || *tmp > 13) && *tmp != ' '))
- {
- tmp++;
- i++;
- }
- if (!(ret = ft_strnew(i)))
- return (NULL);
- tmp = src;
- i = 0;
- while (*tmp && ((*tmp >= 7 && *tmp <= 13) || *tmp == ' '))
- tmp++;
- while (*tmp && ((*tmp < 7 || *tmp > 13) && *tmp != ' '))
- {
- ret[i++] = *tmp;
- tmp++;
- }
- return (ret);
- }
|