ft_strncpy.c 1.1 KB

12345678910111213141516171819202122232425262728
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_strncpy.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: mazimi <mazimi@student.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2014/11/04 16:28:55 by mazimi #+# #+# */
  9. /* Updated: 2014/12/02 16:05:34 by mazimi ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "../libft.h"
  13. char *ft_strncpy(char *dest, char *src, unsigned int n)
  14. {
  15. unsigned int i;
  16. i = -1;
  17. if (dest == NULL)
  18. return (NULL);
  19. while (src[++i] != '\0' && i < n)
  20. dest[i] = src[i];
  21. if (i < n)
  22. while (i < n)
  23. dest[i++] = '\0';
  24. return (dest);
  25. }