ft_strnjoin.c 1.1 KB

1234567891011121314151617181920212223242526
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_strnjoin.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@students.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2016/05/15 16:51:36 by bchanot #+# #+# */
  9. /* Updated: 2018/10/29 12:20:46 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "libft.h"
  13. char *ft_strnjoin(const char *s1, const char *s2, size_t n)
  14. {
  15. char *s;
  16. if (!s1 || !s2)
  17. return (NULL);
  18. if (!(s = ft_strnew(ft_strlen(s1) + n + 1)))
  19. return (NULL);
  20. s = ft_strcpy(s, (char *)s1);
  21. s = ft_strncat(s, (char *)s2, n);
  22. return (s);
  23. }