Skip to content
Augustin LOPEZ edited this page Sep 6, 2019 · 2 revisions

Introduction

The versions implemented in this libft is not the one from the libft PDF subject:

#include "libft.h"

ssize_t ft_putstr_fd(char const *s, int fd);
ssize_t ft_putendl_fd(char const *s, int fd);
  • The ft_putstr_fd() shall outputs the string pointed to by s to the file descriptor fd.
  • The ft_putendl_fd() shall outputs the string pointed to by s, followed by a line feed, to the file descriptor fd.
  • Upon successful completion, ft_putstr_fd() and ft_putendl_fd() shall return the number of bytes actually written to the file associated with fd. Otherwise, -1 shall be returned and errno set to indicate the error.

The following calls are equivalent:

ft_putstr(s);
ft_putstr_fd(s, STDOUT_FILENO);

ft_putendl(s);
ft_putendl_fd(s, STDOUT_FILENO);

Note

Beside the different prototype, this implementation introduces one non-requested behavior:

  • The return value of write() is returned.

Further Reading

Clone this wiki locally