ft_strdup.c 1.1 KB

1234567891011121314151617181920212223242526
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_strdup.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@students.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2015/11/23 14:55:16 by bchanot #+# #+# */
  9. /* Updated: 2016/05/23 14:27:24 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "libft.h"
  13. char *ft_strdup(const char *s1)
  14. {
  15. char *str;
  16. if (!s1)
  17. return (NULL);
  18. str = ft_strnew(ft_strlen(s1));
  19. if (!str)
  20. return (NULL);
  21. ft_strcpy(str, s1);
  22. return (str);
  23. }