ft_strnew.c 1.1 KB

1234567891011121314151617181920212223242526
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_strnew.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: mazimi <mazimi@student.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2014/11/10 14:26:38 by mazimi #+# #+# */
  9. /* Updated: 2015/12/17 15:24:41 by mazimi ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "../libft.h"
  13. char *ft_strnew(size_t size)
  14. {
  15. char *str;
  16. size_t i;
  17. i = -1;
  18. if (!(str = (char *)malloc(sizeof(char) * (size + 1))))
  19. return (NULL);
  20. while (++i < size + 1)
  21. str[i] = '\0';
  22. return (str);
  23. }