ft_charjoin.c 1.1 KB

123456789101112131415161718192021222324252627
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_charjoin.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@students.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2016/07/23 03:06:18 by bchanot #+# #+# */
  9. /* Updated: 2018/10/13 19:51:19 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "libft.h"
  13. #include <stdlib.h>
  14. char *ft_charjoin(const char *src, const char c)
  15. {
  16. char *s;
  17. if (!src || !c)
  18. return (NULL);
  19. if (!(s = ft_strnew(ft_strlen(src) + 1)))
  20. return (NULL);
  21. s = ft_strcpy(s, src);
  22. *(s + ft_strlen(s)) = c;
  23. return (s);
  24. }