/ libft / src / ft_basics / ft_putstr.c
ft_putstr.c
 1  /* ************************************************************************** */
 2  /*                                                                            */
 3  /*                                                        :::      ::::::::   */
 4  /*   ft_putstr.c                                        :+:      :+:    :+:   */
 5  /*                                                    +:+ +:+         +:+     */
 6  /*   By: ll-hotel <marvin@42.fr>                    +#+  +:+       +#+        */
 7  /*                                                +#+#+#+#+#+   +#+           */
 8  /*   Created: 2023/09/14 18:45:50 by ll-hotel          #+#    #+#             */
 9  /*   Updated: 2023/11/06 16:10:30 by ll-hotel         ###   ########.fr       */
10  /*                                                                            */
11  /* ************************************************************************** */
12  
13  #include <unistd.h>
14  
15  void	ft_putstr(char *str)
16  {
17  	char	buf[1024];
18  	short	size;
19  
20  	size = 0;
21  	while (*str)
22  	{
23  		if (size == 1024)
24  		{
25  			write(1, buf, size);
26  			size = 0;
27  		}
28  		buf[size++] = *str;
29  		if (*str == '\n')
30  		{
31  			write(1, buf, size);
32  			size = 0;
33  		}
34  		str++;
35  	}
36  	if (size)
37  		write(1, buf, size);
38  }