ft_putstr_fd

one·2021년 1월 30일
0

✅ft_putstr_fd

  • Outputs the string ’s’ to the given file descriptor.
  • 문자열 s를 파일 디스크립터로 출력

💾Prototype

void ft_putstr_fd(char *s, int fd);

💻Parameters

  • s : The string to output.
  • fd : The file descriptor on which to write.

💻Return value

  • None

💾Code

💻VER 1.

void	ft_putstr_fd(char *s, int fd)
{
	if (!s || fd < 0)
		return ;
	while (*s)
	{
		write(fd, s, 1);
		s++;
	}
}

💻VER 2.

#include "libft.h"

void	ft_putstr_fd(char *s, int fd)
{
	if (!s || fd < 0)
		return ;
	write(fd, s, ft_strlen(s));
}
profile
늘 호기심을 갖고, 새로운 것에 도전할 것.

0개의 댓글