ft_strndup.c 1.0 KB

1234567891011121314151617181920212223
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_strndup.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@student.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2017/12/19 19:32:15 by bchanot #+# #+# */
  9. /* Updated: 2018/10/13 22:48:31 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "libft.h"
  13. char *ft_strndup(const char *src, int n)
  14. {
  15. char *new;
  16. if (!(new = ft_strnew(n)))
  17. return (NULL);
  18. ft_memcpy(new, src, n);
  19. return (new);
  20. }