putnbr - AugustinLopez/libft GitHub Wiki

Introduction

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

#include "libft.h"

ssize_t ft_putnbr_fd(int n, int fd);
  • The ft_putnbr_fd() function shall outputs the number n to the file descriptor fd.
  • Upon successful completion, ft_putchar_fd() shall return the number of bytes actually written to the file associated with fd. Assuming a 32 bits integer, this number shall be between 1 and 11 bytes. Otherwise, -1 shall be returned and errno set to indicate the error.

The following calls are equivalent.

ft_putnbr(n);
ft_putnbr_fd(n, STDOUT_FILENO);

Note

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

  • The return value of write() is returned.

Further Reading