ft_strjoin.c 1.2 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: 2016/10/16 22:13:42 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "libft.h"
  13. #include <stdlib.h>
  14. char *ft_strjoin(char const *s1, char const *s2)
  15. {
  16. char *str;
  17. if (!s1 || !s2)
  18. return (NULL);
  19. if (!(str = ft_strnew(ft_strlen(s1) + ft_strlen(s2))))
  20. return (NULL);
  21. str = ft_strcpy(str, (char *)s1);
  22. str = ft_strcat(str, (char *)s2);
  23. return (str);
  24. }