ft_strjoin.c 1.1 KB

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